From patchwork Fri Jul 26 20:31:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13743177 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 31CE2C3DA4A for ; Fri, 26 Jul 2024 20:31:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C994F6B008A; Fri, 26 Jul 2024 16:31:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C24486B0092; Fri, 26 Jul 2024 16:31:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A76366B0093; Fri, 26 Jul 2024 16:31:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 876266B008A for ; Fri, 26 Jul 2024 16:31:28 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 3D68FA014A for ; Fri, 26 Jul 2024 20:31:28 +0000 (UTC) X-FDA: 82383049056.03.D47DE21 Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) by imf17.hostedemail.com (Postfix) with ESMTP id 8C44B4000A for ; Fri, 26 Jul 2024 20:31:26 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="HOVj/DdQ"; spf=pass (imf17.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722025861; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=WSTjdbMjvEiF4hi3WOb+1xaRPO7PBio6gS846AF8ehU=; b=tDlN7pAjlcGB3owMlBl63+jcqu35ippgzjRW71oJc7w5h4Xp4HCu4oEPKFa+dZAEAX4BW6 eZRJQP7UBWcjmEVjFaF1nGVLGSkp3rZzA9ARjgT+AbA+Gn5UF/zxWLAKbgGkllHJfob19D 8ipr7Tjz3XZQY/+M/q3Q7OTG+HoM4ig= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b="HOVj/DdQ"; spf=pass (imf17.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722025861; a=rsa-sha256; cv=none; b=jT79YOaCR599aom7+iwhrFY2p76MB4fIB3Hz9+eDuL+eBGLkoTjIcqhF6I0OznGGoL5dG6 SFtHGgR9iWr0VJxGl25lBivfZMCaeyBlIx6G96MkMDebdIh/VbDc4LD1DgF3Gq0tTCD/fx rHWv5oXV+shYqZlwizVs7C8mz4EUCzg= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1722025885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WSTjdbMjvEiF4hi3WOb+1xaRPO7PBio6gS846AF8ehU=; b=HOVj/DdQ+WS4c97tS0eRWs7o/fqICrcdjwReWyZXjlwMaJXWEM32CXoiMRuxXaeKL+ADXC L5METOeKuURrgb1mI9sRAswTgjti1SywOP+Urfdyz4KM/ot+4xrki+OdnJSKJ7YO2yPMgW eftStYwv9OrYPBblThhZXyEejHBA7cw= From: Roman Gushchin To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , Roman Gushchin Subject: [PATCH v3 2/3] mm: page_counters: put page_counter_calculate_protection() under CONFIG_MEMCG Date: Fri, 26 Jul 2024 20:31:09 +0000 Message-ID: <20240726203110.1577216-3-roman.gushchin@linux.dev> In-Reply-To: <20240726203110.1577216-1-roman.gushchin@linux.dev> References: <20240726203110.1577216-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 8C44B4000A X-Stat-Signature: pds9mx9x5ny5c9jqi9t5xhwj9k3fbngs X-HE-Tag: 1722025886-932992 X-HE-Meta: U2FsdGVkX18SucI/f8f2EAV9sx5IkkIzJtJJs2ajGAH+Whm7ExN++F1vyzQff9bJI1w4X1/NZiVwWaO1BU20WdlvfcNLhtAd0ggJ+MryLcO8rXu6ZnuSAT3drc6zmEsSVnPQXyMNDI6LwMu+XAabD4HIhTjOIMwrzYe0uhnQuUIU+t4FZUNODWAZ+LeHqc4LATv3IYcFwQGbaRqt1TZqUWyurJYm/sXtw3KC/W46QqlRA7nGqPj8rTJRbxSAbaklNPgB9+Pgj65w9lcQtm58qaQlLM2sn7oUNM98l1ZK7hksEqyKBTHWxBRixAiEFGTIKBZuTNyPqS/r9Sldzw+IxLjXHWToIx3qItsZataoA3wE3Q7RphBuZkLNWtLMd/KqqHHzSyu66EalijJWOd93+eogKkj6MFfuA8Lx1p9+rUc6y2rdiY07v5PuhgqTxwaCwwXe8jDw4l1Tl+X7INbufx/EBSshS2VoDcUiJnvXINEzblpWGn42FyUxxGQ3X1hMSPTyASMVDImEIe7Z+ry3tbnvGGtarn3pNJAlhqMTDZ4zbby36N7huTI6kZukP7/M7sQ/1zyVvSs+UOnfGc/xtsbO9ts/ORtqA/WMi0zBHeG+X+LSyBX2XfCr67AMiVPjk6SEue7mWBv3s2L51JNePesb6agT7dGHbHGOaat8MKAxrYQnyWcCyYTKPzQifRPA7RHDITIgrKkDUuPd5KxyJMvCrYY8jUFzUZEMYN2q8w/G5AAao5edJ5EU3cjciOzdiphZdM4InkZd3A8kDaLPrrq3+42DIAmk69zzVqiDbwAPaIwijmS63A3+KDlOGKyAr2o8AGbE99hPJaq4O9JwnGqXW/tgqkyYh7JhQoL+Qi/vo5W9mMQ7bZOtm7vsCsAMp/0WJaU9UVqTbY8UaS1EQpscy3HY1wq3MlAVhe7+U2xyMUhL1kUzzKM93/eWfFgKsrzxI7f4qi76NoA6fuJ Kpex/V0g BdEYpX3qClMT8BxjgXMKi5prSQQ5tS8It26L8IrcS217LkqSDnr0lzphd+sB0TNeuqq/Zl1Njb6t/9vPKNjlVo2Jh+NePU6J1xpdtdipPfwtUYoShLYv4vYD79Z2CTonGTbM2XEirF+ZfhGXd4OXFMykycwZtL2Q1Ssy+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Put page_counter_calculate_protection() under CONFIG_MEMCG. The protection functionality (min/low limits) is not supported by any other cgroup subsystem, so page_counter_calculate_protection() and related static effective_protection() can be compiled out if CONFIG_MEMCG is not enabled. Signed-off-by: Roman Gushchin Acked-by: Shakeel Butt Acked-by: Johannes Weiner --- include/linux/page_counter.h | 6 ++++++ mm/page_counter.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/include/linux/page_counter.h b/include/linux/page_counter.h index aadd42f5ab7b..cf837d0f8ed1 100644 --- a/include/linux/page_counter.h +++ b/include/linux/page_counter.h @@ -95,8 +95,14 @@ static inline void page_counter_reset_watermark(struct page_counter *counter) counter->watermark = usage; } +#ifdef CONFIG_MEMCG void page_counter_calculate_protection(struct page_counter *root, struct page_counter *counter, bool recursive_protection); +#else +static inline void page_counter_calculate_protection(struct page_counter *root, + struct page_counter *counter, + bool recursive_protection) {} +#endif #endif /* _LINUX_PAGE_COUNTER_H */ diff --git a/mm/page_counter.c b/mm/page_counter.c index a54382a58ace..b249d15af9dd 100644 --- a/mm/page_counter.c +++ b/mm/page_counter.c @@ -288,6 +288,7 @@ int page_counter_memparse(const char *buf, const char *max, } +#ifdef CONFIG_MEMCG /* * This function calculates an individual page counter's effective * protection which is derived from its own memory.min/low, its @@ -459,3 +460,4 @@ void page_counter_calculate_protection(struct page_counter *root, atomic_long_read(&parent->children_low_usage), recursive_protection)); } +#endif /* CONFIG_MEMCG */