From patchwork Thu Feb 2 01:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 13125202 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 47ACEC05027 for ; Thu, 2 Feb 2023 01:42:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 828D46B0078; Wed, 1 Feb 2023 20:42:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D8BA6B007B; Wed, 1 Feb 2023 20:42:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A0AE6B007D; Wed, 1 Feb 2023 20:42:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5ABCC6B0078 for ; Wed, 1 Feb 2023 20:42:20 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2DA18140DC1 for ; Thu, 2 Feb 2023 01:42:20 +0000 (UTC) X-FDA: 80420651640.08.1AC3F87 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) by imf09.hostedemail.com (Postfix) with ESMTP id 5BF07140008 for ; Thu, 2 Feb 2023 01:42:18 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=o9C1yU0q; spf=pass (imf09.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675302138; 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=a7K+pfryiakj921NmwDDKHUHNMkRDDlwHdec1/AfuAw=; b=zLB8BotWR7j6oHfXELk2hpxeXLoVqXKreDIf3Jt3sAvnvkMbi1Eq5QRBMj7wf8i4XqD25I M8Wf0SXBib18+RFu1sOpos3r2IBFWRAm+05NY0SJlq+T5TAEYjTLF2MJ8UEWw3YTjSR61J w+JyaJjmy9G4Ap84WIY0UjPvDclvfcU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=o9C1yU0q; spf=pass (imf09.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.216.51 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675302138; a=rsa-sha256; cv=none; b=NoNsk6jVcle+EGriftka2B4kg6cj+Zg60id/RUOqgGFNvPA59cTpgFr3wl41ZpyJdeNb2M yAbs5fX4Yvt+AN7pr2WVpjLa49I1fYq/ZNrxn55Zv0wu/GtmM7+fJkGNOAp0H2mGXUtaIX fkhJGkaesOSST5/U54g86UNRMWG74tE= Received: by mail-pj1-f51.google.com with SMTP id 88so505487pjo.3 for ; Wed, 01 Feb 2023 17:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a7K+pfryiakj921NmwDDKHUHNMkRDDlwHdec1/AfuAw=; b=o9C1yU0qRyxMb+8TjyXQNQmbHix8uSyQey7fMxpn7WB3cyhyXbe0esxvoUn/cYcC7l sRqr6UOS4MgqlhVNJRLusBxIqf2SRvOxbmza/2MFH/T3TF2WgsTf6ulZlLcAwUF6noqE LxckguhCFANPYNBI/kmrCtTki8+ZuXh6cl7LgJfEj+IgzOCGCsl3vAxhecbvBrHF5Xr4 gJ83wFUazvetJ8aKBIL9iUUqPe4ISRtDM3HOpIrVKZ5J6qbBRaYs8m95ZQHH06AR6Frc N5t/S45+9qe+JRQr/EubCBbF+2wBXVShFKEz7oMxUh6Hu6SELFnKpfc5AkwS+THIeB6m AALA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a7K+pfryiakj921NmwDDKHUHNMkRDDlwHdec1/AfuAw=; b=TJev+hCrnjKQ+vEUXd6EeEYLBthb8TUUPW3ZEcmVIOzc2oqrku7e13vigu21lMWk6c lRqrwUT+eP9YgYEmXbRPv+jzVwLMDO6VKzq31dXSMTIyfwZVVTzF8YkeK+/VFXmLFtlo wJf7gJubRnbu+LyN8mylJBSMIrS3+WrwiaZmxpkFZVUpmqMo3mTx4xhGfUS7mBSeiHuZ 7Wa/CnDethf8J80EQUsPfp726/HxNYXE7Gy0MwTtaTZWEsyCWQJWn/Rxn76Xl2OuzLhp WKc76iZsXW2WUGXC17IlT3T/0R54yqLXEAGPUyhGcDJc4wky7lKVXJD4QkBBaprpqQaN iT5A== X-Gm-Message-State: AO0yUKXjM2T2xWlsy/2UC+mvc+3GGCc4QNE6r4d8VPPdBGFNhnKMYMe2 ytPW8U1iygqYHgB7cUaGiIo= X-Google-Smtp-Source: AK7set/GHLWgQK5/vzlqcUo2kY9V/MdT1dT0WTXwTEy8hgxP1zeDjhfySKsD37XrNnwjv0OVSqcuSg== X-Received: by 2002:a05:6a20:1605:b0:bf:40b:2db with SMTP id l5-20020a056a20160500b000bf040b02dbmr5874632pzj.22.1675302137265; Wed, 01 Feb 2023 17:42:17 -0800 (PST) Received: from vultr.guest ([2001:19f0:7001:3f48:5400:4ff:fe4a:8c8b]) by smtp.gmail.com with ESMTPSA id t191-20020a6381c8000000b004e8f7f23c4bsm6594205pgd.76.2023.02.01.17.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Feb 2023 17:42:16 -0800 (PST) From: Yafang Shao To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, tj@kernel.org, dennis@kernel.org, cl@linux.com, akpm@linux-foundation.org, penberg@kernel.org, rientjes@google.com, iamjoonsoo.kim@lge.com, roman.gushchin@linux.dev, 42.hyeyoo@gmail.com, vbabka@suse.cz, urezki@gmail.com Cc: linux-mm@kvack.org, bpf@vger.kernel.org, Yafang Shao , Vasily Averin Subject: [PATCH bpf-next 1/7] mm: percpu: fix incorrect size in pcpu_obj_full_size() Date: Thu, 2 Feb 2023 01:41:52 +0000 Message-Id: <20230202014158.19616-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230202014158.19616-1-laoar.shao@gmail.com> References: <20230202014158.19616-1-laoar.shao@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5BF07140008 X-Stat-Signature: qbrkrn6b4mjk7x473taw7tsmjm1xw6wj X-Rspam-User: X-HE-Tag: 1675302138-605915 X-HE-Meta: U2FsdGVkX18qboEQejD3gkNF3RC/bq4tWAhOD2gNcrUJiMpy0IroBn4+qQkqnkGrx79svQJuu48fAZhybx3Lhjeioln8D/3697T5auhNtmxSbdKrp2NHoWNlbRaZxDPv2ItDc8qPL/mm94J8Bt93I0ozA+hKnVfrRHX0kAsRpNelWe7fWWa4ntRya9X98OH3IwsJzr8ww6EA4i/A0eBqTazZmrmrv9SMgK+WENgNId9ngwbpSr8US8CfRU2znOD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xiZV2UmIOTT69+4yP4GZYS58qqxeC/xaN1a1LDYzp6LrWQf17J6WyN0TS4tTCWUzn4CXnSf2OyzSaunkZev7y7MEx8S83P1i5Wl0p6nxGZH2LUCqrUZjjy3XAodlAdyztKf03VY3K0Uy5XkGheANas/IAmMj/xBdHLvehUmyOxJT5C4Z8XWduPlJcaQVeri8/627xtYcCehvkgszsSf9fDsQZsAp+A0GYDUVph/YsdqTY63zVwlncEuh5D/lUNDX+lHvRTXttr/HgOs+BKiALUnVm7u5q6zXaSWuPXX4bFdrWhIntC9G7Ykl9+1JvzQxn3ofUQAlVkhAHRrHS7Qk14DvvwO4eLwy3OVweK7agrxMJTfrRmmaWsDFDGFpQ1bOMPvg3fAKofQOjkMlBJK96IPWcdrC7OwByQrbtkXRgCZVpuisE= 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: The extra space which is used to store the obj_cgroup membership is only valid when kmemcg is enabled. The kmemcg can be disabled via the kernel parameter "cgroup.memory=nokmem" at runtime. This helper is also used in non-memcg code, for example the tracepoint, so we should fix it. It is found by code review. No real issue happens in production environment. Signed-off-by: Yafang Shao Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Roman Gushchin Cc: Vasily Averin --- mm/percpu-internal.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/percpu-internal.h b/mm/percpu-internal.h index 70b1ea2..2a95b1f 100644 --- a/mm/percpu-internal.h +++ b/mm/percpu-internal.h @@ -4,6 +4,7 @@ #include #include +#include /* * pcpu_block_md is the metadata block struct. @@ -125,7 +126,8 @@ static inline size_t pcpu_obj_full_size(size_t size) size_t extra_size = 0; #ifdef CONFIG_MEMCG_KMEM - extra_size += size / PCPU_MIN_ALLOC_SIZE * sizeof(struct obj_cgroup *); + if (!mem_cgroup_kmem_disabled()) + extra_size += size / PCPU_MIN_ALLOC_SIZE * sizeof(struct obj_cgroup *); #endif return size * num_possible_cpus() + extra_size;