From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2D956C433EF for ; Mon, 7 Mar 2022 20:26:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A94A8D0002; Mon, 7 Mar 2022 15:26:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9569F8D0001; Mon, 7 Mar 2022 15:26:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 844F48D0002; Mon, 7 Mar 2022 15:26:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id 766C98D0001 for ; Mon, 7 Mar 2022 15:26:21 -0500 (EST) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 37F918249980 for ; Mon, 7 Mar 2022 20:26:21 +0000 (UTC) X-FDA: 79218722562.30.B8E002E Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by imf14.hostedemail.com (Postfix) with ESMTP id 8D808100006 for ; Mon, 7 Mar 2022 20:26:20 +0000 (UTC) Received: by mail-qt1-f182.google.com with SMTP id o22so4691819qta.8 for ; Mon, 07 Mar 2022 12:26:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KprrQH1QijFIErMNifd2yRZ0xh4TY3NxR795MTCn9/0=; b=DF+j831uud0ehC8Iot5YYLdAtSc5oD2NrPm76lVdfTNJl9JJ7+vWt5UeSsDzbjRJO0 jV2vXTyaRVDzvzje3ofwNBzcwfjJZijC/YerDdKQVKFf34v6W9uIdgOwDOKPvRxP8pkC EAmieB+8w6LvB5jTCojeu3LWJBRFcP/gZpbHPmE1Os90sREv7OLFAd0WjdkRyg3xn2+/ iNtB1JK38BaXVMs+dzWJEiOs8TbjXwbqV8bhQVU38MoRJY56RRsBpIbB7UFGOgE0l1oE Z6LlOxs/WXBp3F0bI+ShtfsdA1DVVE9oRz7kVZh14esweCcZyTNv91L8gsJ6UqFgfk0F lq1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KprrQH1QijFIErMNifd2yRZ0xh4TY3NxR795MTCn9/0=; b=4X1sgr7mB5VQIlnRTC7Kll2zHe8BmhaidMZ/tI4meCHHbOICdZ2IzkM/TNJrFkcCFB DnO6OYzH6jpHv/zXbxMfFGelCFA5tFL7uKRX7qcNjmeAO5TSZqmJf7g0Tb7AUmI8ZvTV LYaP+cXk8vzceSuTawGow74tYxRZ1F78miod0T57KzFj85V+I2sByfOTLWt1PExnWjDh n4chlcCaTCzv5Q1Q+USDMWmk6ewbC07nHxq/kACLVxR0CNCvyRkvP/WJqwjjAmCK7UFW jbzZnQenB1d8VSOEqPMRprnke/1tWXcLaYBgWtt8D+DB6PsrXBq4A+hMmndOgrYIDlsQ k49g== X-Gm-Message-State: AOAM531q9TNrpXlyu43aLVnZ9Uvh7DBiXtDnvbDvrjNeEWJnbWklBf6q AA26Y6/nC1IuAY8fTt/7zvqNQw== X-Google-Smtp-Source: ABdhPJxLLT0zTuav5G92BtvC/GKismVLWwCbPS9aMrxrXHHw1MtGKvaCB5oc6UfQOK0gP/ewpRMZkw== X-Received: by 2002:a05:622a:3ce:b0:2df:6da9:1b58 with SMTP id k14-20020a05622a03ce00b002df6da91b58mr10761095qtx.438.1646684779828; Mon, 07 Mar 2022 12:26:19 -0800 (PST) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id e20-20020ac84e54000000b002e06753cf70sm2507980qtw.6.2022.03.07.12.26.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 12:26:19 -0800 (PST) Date: Mon, 7 Mar 2022 15:26:18 -0500 From: Johannes Weiner To: Shakeel Butt Cc: Michal Hocko , David Rientjes , Andrew Morton , Yu Zhao , Dave Hansen , linux-mm@kvack.org, Yosry Ahmed , Wei Xu , Greg Thelen Subject: Re: [RFC] Mechanism to induce memory reclaim Message-ID: References: <5df21376-7dd1-bf81-8414-32a73cea45dd@google.com> <20220307183141.npa4627fpbsbgwvv@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220307183141.npa4627fpbsbgwvv@google.com> X-Rspamd-Queue-Id: 8D808100006 X-Stat-Signature: fy69h1hnn8u5yxtxrty484gkd76etzpa X-Rspam-User: Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=DF+j831u; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf14.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.160.182 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org X-Rspamd-Server: rspam03 X-HE-Tag: 1646684780-827590 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Mar 07, 2022 at 06:31:41PM +0000, Shakeel Butt wrote: > On Mon, Mar 07, 2022 at 03:41:45PM +0100, Michal Hocko wrote: > > On Sun 06-03-22 15:11:23, David Rientjes wrote: > > [...] > > > Some questions to get discussion going: > > > > > > - Overall feedback or suggestions for the proposal in general? > > > Do we really need this interface? What would be usecases which cannot > > use an existing interfaces we have for that? Most notably memcg and > > their high limit? > > > Let me take a stab at this. The specific reasons why high limit is not a > good interface to implement proactive reclaim: > > 1) It can cause allocations from the target application to get > throttled. > > 2) It leaves a state (high limit) in the kernel which needs to be reset > by the userspace part of proactive reclaimer. > > If I remember correctly, Facebook actually tried to use high limit to > implement the proactive reclaim but due to exactly these limitations [1] > they went the route [2] aligned with this proposal. > > To further explain why the above limitations are pretty bad: The > proactive reclaimers usually use feedback loop to decide how much to > squeeze from the target applications without impacting their performance > or impacting within a tolerable range. The metrics used for the feedback > loop are either refaults or PSI and these metrics becomes messy due to > application getting throttled due to high limit. > > For (2), the high limit interface is a very awkward interface to use to > do proactive reclaim. If the userspace proactive reclaimer fails/crashed > due to whatever reason during triggering the reclaim in an application, > it can leave the application in a bad state (memory pressure state and > throttled) for a long time. Yes. In addition to the proactive reclaimer crashing, we also had problems of it simply not responding quickly enough. Because there is a delay between reclaim (action) and refaults (feedback), there is a very real upper limit of pages you can reasonably reclaim per second, without risking pressure spikes that far exceed tolerances. A fixed memory.high limit can easily exceed that safe reclaim rate when the workload expands abruptly. Even if the proactive reclaimer process is alive, it's almost impossible to step between a rapidly allocating process and its cgroup limit in time. The semantics of writing to memory.high also require that the new limit is met before returning to userspace. This can take a long time, during which the reclaimer cannot re-evaluate the optimal target size based on observed pressure. We routinely saw the reclaimer get stuck in the kernel hammering a suffering workload down to a stale target. We tried for quite a while to make this work, but the limit semantics turned out to not be a good fit for proactive reclaim. A mechanism to request a fixed number of pages to reclaim turned out to work much, much better in practice. We've been using a simple per-cgroup knob (like here: https://lkml.org/lkml/2020/9/9/1094). With tiered memory systems coming up, I can see the need for restricting to specific numa nodes. Demoting from DRAM to CXL has a different cost function than evicting RAM/CXL to storage, and those two things probably need to happen at different rates.