Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2605001rwb; Fri, 11 Nov 2022 11:47:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5qM/tConBCzNDul8RZs8hFbFPG09C1KfpziE9zM2GVbaT8j7F1YvD6nKCa72/ma105NCoJ X-Received: by 2002:a17:90b:4fce:b0:212:d5e6:4e38 with SMTP id qa14-20020a17090b4fce00b00212d5e64e38mr3532164pjb.160.1668196024306; Fri, 11 Nov 2022 11:47:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668196024; cv=none; d=google.com; s=arc-20160816; b=gneKECnxQTHCq41qQlGpKw/E4fezLIn1/aJj+sNBKhdFfaJf4ITWa+1aFQjUFHCQg3 FCk69TYRs5dURuKuk1+MSxVGVRi5S8TxGYQynyM//yWcpvx/rFleieEHhAWDmVaEkrhX Uuxm108ejO78RCh2ZCw5X+Ua5bOqtLE0BxyVyKgG1DG1G9zWpmjifIDsFpWi2+8naNVn yYq0nMlK1PVdKwwKaSsik35aoctNvPs5DiLcAYSLuRYj2BfxmPuRF2+2MRf6/QcXCtsR aF71LX2/AdI7yYeE6mW5Wyne1k2V3BqXbS9+p85ArNfdonpS6LyH3zJgaipFemJs0sZS HIJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=VFgOYEQ6NOhR14F+o1liXDfDhEK9cBQJ7rg815eUQn8=; b=QRx0L1FdwumfKhkHCyrsGt1phADxVzTDjK+feOGCOvRwslNaU/NmxhMx5EsQDvS0sC 1IyisMbBzRWFVHvbQ2ex4w1bpXkqodOCUEFYGdVs8XtGHhdtJVA62mKMv9c4vAxSM7BF jnXftvlJXFBhcSt2udAyGoMp1LudXVo6rReO1nXcVubzQ4uFG0L1UxWUhR87oLA+9Tep 6tZ5eHafu60j2424KdA4letcSIVvAnlCoVPFue//uTeRICCwWduzsw9wEmVHenfBCgr7 QEi3EcR9nrDrLXHjGU9/mLBq4G8cKC2+MlPm78oTswKPWl5yg7wgFkrjUd/LFsbm22Sh BGiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=N6wKqF8y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a636c06000000b0046fed3af6c9si2900071pgc.370.2022.11.11.11.46.51; Fri, 11 Nov 2022 11:47:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=N6wKqF8y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234019AbiKKSYp (ORCPT + 90 others); Fri, 11 Nov 2022 13:24:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233990AbiKKSYm (ORCPT ); Fri, 11 Nov 2022 13:24:42 -0500 Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF9A14D5C4 for ; Fri, 11 Nov 2022 10:24:38 -0800 (PST) Received: by mail-io1-xd36.google.com with SMTP id 11so4162571iou.0 for ; Fri, 11 Nov 2022 10:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=VFgOYEQ6NOhR14F+o1liXDfDhEK9cBQJ7rg815eUQn8=; b=N6wKqF8yyEt+Eo6I+YHl1q4P0AiwetFsOZQGEI+Xq9xFJz0aQPV1YS8smiPR5fq8tw 8HGxIaRNTcgdsULpAgSBfAUzKw8X+BuKmgrdfJVjEZQA+daVSKvyPziVjoG3BnbNalFi KI0TIyRwmMMher+y15JVLg9Z8qiY8H+LIcipf2u8ithG+kYyKO9EdAXW06OY0nd5SzgF UlIuOHYW0oFo0Bc3iS6P5+JiFMwHDodZekYcXrSE8DGpNm3CHtc4jK7j1WlV1VJRrUYG 77YuD/S6xG4OWiHiPDMxXwbDs/+4RHBwiRn22XPv7C7r5aBO6sac4kB+aRprIyoHee8Z isaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VFgOYEQ6NOhR14F+o1liXDfDhEK9cBQJ7rg815eUQn8=; b=Saev371fWjm+t2+rCz2STBvnLcKsj5Ou7kztlQ1RdKC8vtALqjyT+qoofqVuoJPIoz liTvUXc1sTz27sx5a7QfcRsbvNkY3j3h8cbIHnDaLeLdlHvrVYKzcQuOWSSwNv2gtnVN lRVZ2Xk+1S3Lg5Eml9PkKJXKk3erLvGCfbTnSIfFu31X0pfsAtYwFw+OV/518iS/3mto dfT3f+PMTWV7zY0wtdOMbPIMJfhhAQGZ5zxtjD3uEd9DAMudGo5nfIMxXzLvbFtWRjQN EX6rlj6ACvyl+HgZEtwIh7+dCDQmm22+i3zJET2cnj+8AgEnDauHtWi4gaWSyrJISl12 4MjA== X-Gm-Message-State: ANoB5pmCT2eIUOCXJRhaq85i9T41BC4Rx3/cfpf2qTvHqyrKj97FUskd P29tapwnyW9/Obgj7MpJujJURihYbbuoqzi+QRSJ4Q== X-Received: by 2002:a02:2b10:0:b0:375:1ad6:e860 with SMTP id h16-20020a022b10000000b003751ad6e860mr1381798jaa.191.1668191078126; Fri, 11 Nov 2022 10:24:38 -0800 (PST) MIME-Version: 1.0 References: <20221110065316.67204-1-lujialin4@huawei.com> <20221110144243.GA10562@blackbody.suse.cz> <20221111100843.GG20455@blackbody.suse.cz> In-Reply-To: <20221111100843.GG20455@blackbody.suse.cz> From: Yosry Ahmed Date: Fri, 11 Nov 2022 10:24:02 -0800 Message-ID: Subject: Re: [PATCH] mm/memcontrol.c: drains percpu charge caches in memory.reclaim To: =?UTF-8?Q?Michal_Koutn=C3=BD?= Cc: Lu Jialin , Johannes Weiner , Andrew Morton , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 11, 2022 at 2:08 AM Michal Koutn=C3=BD wrote= : > > On Thu, Nov 10, 2022 at 11:35:34AM -0800, Yosry Ahmed wrote: > > OTOH, it will reduce the page counters, so if userspace is relying on > > memory.current to gauge how much reclaim they want to do, it will make > > it "appear" like the usage dropped. > > Assuming memory.current is used to drive the proactive reclaim, then > this patch makes some sense (and is slightly better than draining upon > every memory.current read(2)). I am not sure honestly. This assumes memory.reclaim is used in response to just memory.current, which is not true in the cases I know about at least. If you are using memory.reclaim merely based on memory.current, to keep the usage below a specified number, then memory.high might be a better fit? Unless this goal usage is a moving target maybe and you don't want to keep changing the limits but I don't know if there are practical use cases for this. For us at Google, we don't really look at the current usage, but rather on how much of the current usage we consider "cold" based on page access bit harvesting. I suspect Meta is doing something similar using different mechanics (PSI). I am not sure if memory.current is a factor in either of those use cases, but maybe I am missing something obvious. > > I just think the commit message should explain the real mechanics of > this. > > > The difference in perceived usage coming from draining the stock IIUC > > has an upper bound of 63 * PAGE_SIZE (< 256 KB with 4KB pages), I > > wonder if this is really significant anyway. > > times nr_cpus (if memcg had stocks all over the place). Right. In my mind I assumed the memcg would only be stocked on one cpu for some reason. > > Michal