From patchwork Wed Jul 24 20:21:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 13741326 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 A7F9BC3DA61 for ; Wed, 24 Jul 2024 20:21:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED2926B0089; Wed, 24 Jul 2024 16:21:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E09596B008A; Wed, 24 Jul 2024 16:21:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD0A36B008C; Wed, 24 Jul 2024 16:21:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id B776D6B0089 for ; Wed, 24 Jul 2024 16:21:18 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 74674160B9F for ; Wed, 24 Jul 2024 20:21:18 +0000 (UTC) X-FDA: 82375765836.15.6CA24BC Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) by imf11.hostedemail.com (Postfix) with ESMTP id BED7940025 for ; Wed, 24 Jul 2024 20:21:16 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=T4pLX8wN; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721852437; a=rsa-sha256; cv=none; b=RD58yaoNKOyfNQK0GW8pomO+1rW80j76syf4NZRxvmIzL2blhO8ost2xf0t4YP40OfOaws QBrftTDY0HNEEgrBDzSZdMj2gLNNoTwozmLNWf8OP6L2IxuT/4t+rinrACEODKG+51usDN sGAFP+957qH9uycPX8J+rECiKIiz/ck= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=T4pLX8wN; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf11.hostedemail.com: domain of roman.gushchin@linux.dev designates 95.215.58.185 as permitted sender) smtp.mailfrom=roman.gushchin@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721852437; 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=lYZidUGk8Ov2rzxeyGytgB3mibsabUB7JDKLCQIcDhM=; b=Lgk6UKUPVN0wTEW+nKkl9arjJHWQmcnc4FJy6oEp7d5g2GXvacl4uXlW/z1H/qZE/lP5Us rV4xWVrb9OEQIRMFi30AGWignouNzrmuzr4Houwn6DSlRYbETDrdbqwlRuMtkr5y3KWG5z ob0wjDusJc5dK2fePTW6rwTX0OxuHvw= 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=1721852475; 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=lYZidUGk8Ov2rzxeyGytgB3mibsabUB7JDKLCQIcDhM=; b=T4pLX8wNIKFmF53zTNuwU/H5E2+h8nH7GHs80XJpR/tkYgGQ9BpQw3b0N76p3VmP4HzeF1 Od8siMmfRV+Q2jRv3r8YdSVxtJW1KHydUAOZcyQ4c0w2A4a821Q7OaBO6sm0BIoT1hVKV5 oYYJvY32MTZK4U4DP4Ozv2hK5835KJ4= 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 v2 2/5] mm: page_counters: put page_counter_calculate_protection() under CONFIG_MEMCG Date: Wed, 24 Jul 2024 20:21:00 +0000 Message-ID: <20240724202103.1210065-3-roman.gushchin@linux.dev> In-Reply-To: <20240724202103.1210065-1-roman.gushchin@linux.dev> References: <20240724202103.1210065-1-roman.gushchin@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: BED7940025 X-Stat-Signature: zr396ag1stkzrtpp17pwm6wn1pnpesee X-Rspam-User: X-HE-Tag: 1721852476-302214 X-HE-Meta: U2FsdGVkX1+oDS2BiqHwiQlzzUu8QhfzJv7fv+iweMtDp/nYVl29rCshMq4quNejfo9iWzXaOAZZE6YKLKQQOO5Q2bvpd0E3+pIC/GSTFXBy/lZmr8Ol6oSg3/IgnA8SW0BvlKYNkuZVNW23RREewkWvSBeJ5pXhpNRQsnV4tXJNkZTgfa6UlMaVfYCACMzW4Gujy257bzKMMVMwC6cxarwLP7XhC3yquPIoX7ak2hid563lLHpn9VPoJr+tpharHovJKWhYgX1lNdbESyxSDua0YI4pFuzmj7S214TuGl8s0EKdEn96GVp0v6OMBwYI6iugJThRYNmrAydMJq8wDbyFHeHM2KTb2foMYZfEKDfqtIW2zl6uinHhq5S61pADnvfyKNzh5tk/uJ7cNzzlmx4K/F0y3jJRmTAq3MSgfOD58TojPZY0Oy+g3JBmCOpOmKjLlQy08/XuOQGIV00nokHZEu1bpdGAIUwFN9F5hGY6VpESa0/iFj4ReBtX20QZ8uigOYJnKx+zjpV8KoRAfrCrbDr6gUKJq1oiYTHjjj0kdkfyCyYG/YoWraVwoZQZUm3t4jvz0GkfOW9uJuxi2R4jlytFXux4+L/9kOPm0mBlOxg33O+gXBgSLKEnp632qz2+leNY/+DsGE9jC17lMYJZH2oXIFUeZ5C/cHmKYtzrJfxT2zWx6oJnEHBK8KLzKUvUgXgIxOD3Ln/BH+GRVm3HJ+PFbzIge+iDpdjsEqYapWKKvYh6AEmi7rnNmbtD7hGOpRaFUdvvFEEMy2BfFqVY/lKbDmM7YLklrb/gmP2ILd9mad0l9bzJSIuaXt2wRmh9ZpD8aN9cSA3jmU59T5m25FTlKhGBqyF0oF9sG61tzIwfnagLsadLVbXEpKqusNjAF/bMXtiIgtlhIoK5EUlwbKsuqF0xMeaoPxGEuxnCK4/lSnBg4sY15BiWALVzL7zUDPfXFuWFp7KXeGs CfDJEgO7 5m1Zxqzx2pJwSIOr6InY11CuzcCHVtFzdXZXi+lSWY3aj1HVMmtRLY8VLpHtzAh5szgFb8dTEktgZoliWaWKKPHoYSxrOglIPrrBy5cPcvgVkRu6ip6UDCXM4ucGdpS54b1bUk1dfc/Epx9P4hlHFHOqaRtGMczV1mgq6 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 --- 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 b31fd5b208aa..d85fc7df3280 100644 --- a/include/linux/page_counter.h +++ b/include/linux/page_counter.h @@ -91,8 +91,14 @@ static inline void page_counter_reset_watermark(struct page_counter *counter) counter->local_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 */