From patchwork Tue Dec 24 01:14:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: JP Kobryn X-Patchwork-Id: 13919576 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 67F26E7718B for ; Tue, 24 Dec 2024 01:14:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3D9356B0099; Mon, 23 Dec 2024 20:14:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 385976B009A; Mon, 23 Dec 2024 20:14:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FFB96B009B; Mon, 23 Dec 2024 20:14:29 -0500 (EST) 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 E61B56B0099 for ; Mon, 23 Dec 2024 20:14:28 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8B95514196C for ; Tue, 24 Dec 2024 01:14:28 +0000 (UTC) X-FDA: 82928080410.19.7E04A03 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf28.hostedemail.com (Postfix) with ESMTP id 9CF4FC0016 for ; Tue, 24 Dec 2024 01:13:44 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X9LKSG2X; spf=pass (imf28.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=inwardvessel@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=1735002841; 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=Gm9yai/osEcIq2t3vZy97c5K46GB7iT4Bhg8cC3aZ6k=; b=BpniXAcnt0AKtUptZ71MW398Jzf+sQ2X+6yTHavaJLfZYd0YPHZhC3oOJ5eFdwbKW47bdm iTOUNtYPQZxlJNyQmMIZCY7rLpjEMGiH/W3CPjh/kdszwYwm23PrRxbaw62c72FQBwn244 zephq8ecEuwOtCEpNyBELB7mbDVepJQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735002841; a=rsa-sha256; cv=none; b=L2gyE39zxGXKA74R4oYMNJHMjo8Zfj+QduTpa8q+4v8jypcO5B+UQco8yxw5xiPe2R9xP8 l2K8NATJXGN395HVIKy5Mlhwd0epW6kYAgcl63SwhSg+rRT+Fyy+JfAkl0BZIKRsBOaivH +/gziWxGEmi8IJX1bTY3jjAklqxB3fc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=X9LKSG2X; spf=pass (imf28.hostedemail.com: domain of inwardvessel@gmail.com designates 209.85.214.171 as permitted sender) smtp.mailfrom=inwardvessel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-2167141dfa1so43808845ad.1 for ; Mon, 23 Dec 2024 17:14:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735002865; x=1735607665; darn=kvack.org; 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=Gm9yai/osEcIq2t3vZy97c5K46GB7iT4Bhg8cC3aZ6k=; b=X9LKSG2XV8XzulsQnQ/3R2m7iI4JaTQHw2CXgmiC/SGLvNh1s2YXQ6nCm/PIGzP7fs 1sHspt9zQYBWlK+PmJnR2wkDsKrg0n1L0/z64TWOHIw9OLcSTK8+yvRvGAfVeMJhLE2X CMAYrYNC4arUzoe6nVmmRJO5qI6/Kdp+vgQ808v6LoijeriSVkYcm5ggYiYpqgd1oLun W814F/aSv3HEGSgZUl6QVtHG1H22zkoMBU14EofClok5HHvj57TdN+85j6KIHi975YNC r87vPP9zJZ1XgBZf/eJsNnB+P/noOQm3gyIDnB6c+UhWxGtnCUGC8Lc8nHF6ofaipgOO t7Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735002865; x=1735607665; 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=Gm9yai/osEcIq2t3vZy97c5K46GB7iT4Bhg8cC3aZ6k=; b=IKkQavUhUXYFt8IFm7BdblFGcIrA1L6ICasmhzaTBFNB5ySgh2bxBoQS3fMh9bcR2a +6tPaOuyzWNhnkJw3FBy+1dIIpYHpRLmVoTO99bUNGTwJqL5d+XWF9Allw0rtX9B7xpX uYkB8Y9mgBMtWVG9Xk6f7GOP4Xg/kZ2h93zHYqEp1E6fR9u7SJw+cgDcLNRHr779ZvaM pwmKkcrDSbrROUxgrzlk5cKxmHqWGR49pg5oHjrlaOQoRo3BQDbMNN08YGRqIwdFcS2G jZdntIgi1M1PbG7skDKuOvgrrgqNMrZJFaZYmKNoFqeEuFdNU582TYhQ41ecNOp3owvb aaTg== X-Gm-Message-State: AOJu0Yxuo/H2zT7+ZTyCzlUO+Cdo6/NIH3KENTvsZLlRgYeqQKFm+Jdc qA8TI8KI2qwfInNhWyTa0F8gYUsBMIqgg/Kp18BajyHyNf+ihUyo X-Gm-Gg: ASbGncspnaW68NaQfbifQ/Z0/TEzKLt6/zlcqJf4n88auo7ZnQWEfIuh6BYjSC8dZdr p0Bw6lNS8yrHQvOlUDTACUmxFHMcCht3vPsGubtokirjSxsAGLdLoYvDtL4kA5r/C5qT3RD7jTJ T6IiYVyf/GmlA+j2Ahz6Rzj7y1SqpY8Z8cP+TjppDcZ1e9WNF7Bfkx4o9/9vDZU/kAAD5qJHvkH 587+gjOkdf7pk3gJT2PaNCATnRZN52I2E1F9dRqTq0e+yDD+SFRmvKHpENhlE8U3Lk4pNkAui91 Gd9iOBhqY9I42wHZQQ== X-Google-Smtp-Source: AGHT+IEqRtFE3SjYN8vE3ZEp1iTgfgoCrR6J9QQ+lxWuXPA4f3+IfoIE2/oejmcZygYdV0QTvV6Ahw== X-Received: by 2002:a17:902:f646:b0:215:ba2b:cd55 with SMTP id d9443c01a7336-219e6ca6c61mr244012185ad.2.1735002865450; Mon, 23 Dec 2024 17:14:25 -0800 (PST) Received: from saturn.. (c-67-188-127-15.hsd1.ca.comcast.net. [67.188.127.15]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc970c84sm79541255ad.58.2024.12.23.17.14.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Dec 2024 17:14:24 -0800 (PST) From: JP Kobryn To: shakeel.butt@linux.dev, hannes@cmpxchg.org, yosryahmed@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, cgroups@vger.kernel.org Subject: [PATCH 9/9 RFC] cgroup: avoid allocating rstat when flush func not present Date: Mon, 23 Dec 2024 17:14:02 -0800 Message-ID: <20241224011402.134009-10-inwardvessel@gmail.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241224011402.134009-1-inwardvessel@gmail.com> References: <20241224011402.134009-1-inwardvessel@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 9CF4FC0016 X-Stat-Signature: pt59ceeyow8anjsx1qwiyb5aaext43bx X-Rspam-User: X-HE-Tag: 1735002824-516925 X-HE-Meta: U2FsdGVkX1/20yfWkA+p3HCzc9pp+h74ZKtoSUGVLqyHTG1YcTY+pr83YjKSa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EKcSIuCwFxwNQP0Pdt+x5K3Jb6jk2WA5HKdIJHcnxHDPnfOw3PxI2MH/RbtcXVCOIguhMqLleI6lxGnRc1K53acPCFwu8+4eHmVPTjEu69OsXeKYpasIBbcVkWKS5Rg/m7gUWo3x8CUuxRW8cfTvIfw5HR5B0VxfmK/HEyD75THnhuzy8812oBguqu05qxlG1y9Y8WaFTWMu034lJ8hGml5sWsOawQnKIsOLOL0DbhtfQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.147277, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: If a given subsystem is not the base type and does not have a flush func, do not allocate. Signed-off-by: JP Kobryn --- kernel/cgroup/rstat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c index 03effaaf09a4..4feefa37fa46 100644 --- a/kernel/cgroup/rstat.c +++ b/kernel/cgroup/rstat.c @@ -423,6 +423,9 @@ int cgroup_rstat_init(struct cgroup_subsys_state *css) { int cpu; + if (css->ss && !css->ss->css_rstat_flush) + return 0; + /* the root cgrp css has rstat_cpu preallocated */ if (!css->rstat_cpu) { css->rstat_cpu = alloc_percpu(struct cgroup_rstat_cpu); @@ -445,6 +448,9 @@ void cgroup_rstat_exit(struct cgroup_subsys_state *css) { int cpu; + if (css->ss && !css->ss->css_rstat_flush) + return; + cgroup_rstat_flush(css); /* sanity check */