From patchwork Tue Jul 30 15:01:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13747517 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 D4A88C3DA49 for ; Tue, 30 Jul 2024 15:02:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 070126B00A1; Tue, 30 Jul 2024 11:02:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE96B6B00A2; Tue, 30 Jul 2024 11:02:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D14CA6B00A3; Tue, 30 Jul 2024 11:02:38 -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 B170B6B00A1 for ; Tue, 30 Jul 2024 11:02:38 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 2063CC0371 for ; Tue, 30 Jul 2024 15:02:38 +0000 (UTC) X-FDA: 82396735596.27.CD6F7C4 Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 2B31018002E for ; Tue, 30 Jul 2024 15:02:34 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=jZz+bIr9; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf24.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722351710; a=rsa-sha256; cv=none; b=CMr4b7mmiVVRB7XBz4yiiTG5uKVG/FtSgR0LA3tVdOIkGpq+zf1in3J4RD/CSbqhRXqSWl vwrssfJFis88uhWn7nhxSCxQtQH01QxySD19dIBjJL0p8gvNVIiVb7RWOiZpkvXVbcjr4+ uWQ0JHm8/54qBkhoX5V/EUlmNlh+LWo= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=jZz+bIr9; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf24.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.172 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722351710; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2aHnBGDy68xwYXXDjrfSbMfL0AOPRRbHUN6FtVmc8lU=; b=8BWFiAC4cTN3JtrQ3EKrdwtmutyVjgG5YvNXw6GpJBHda3zO904iP2IRW48a/AMjn6g0X/ QJoRap5diBZyqYzBpSU/JrrJXYeiCZHD2vmgKnqVGMPmfYp4i2HaWAvRR2k8hUcrIysRUj wp81POVBns732mVQIFqWfxa0VSVfT8Y= Received: by mail-qk1-f172.google.com with SMTP id af79cd13be357-7a1d7a544d0so326074985a.1 for ; Tue, 30 Jul 2024 08:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1722351754; x=1722956554; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=2aHnBGDy68xwYXXDjrfSbMfL0AOPRRbHUN6FtVmc8lU=; b=jZz+bIr9mzq38RSca2gAyvyA+mgwPVp5OlP05PrLaFnVwS/WBkTdBk8IVQLB6BUn0I jtCQnKjebcWxEyhAW0NKoMuSn0fckhkr7agmueY+VCG8mNroIJwJQF+ecPtJsuBk0Jwc ZtKu8rj+dSunfOt2JnYYx8BOLNYkoXWoQLBeoO4bvq8OyUGMDF9gbSLmFf+XMVIm2bcN qMKUcLgkGVDLxY2ofjLhaLEjBwYHQjaweaLbn3yx/tBnDEC/Cd+x+WSfetBG7OgJNTQR qm5fRFcP0lfu5Hrgl9dX/x4BwLZHokTihK/QxQeUlCW+w/meZ7AOtvwKe3Q697XXkRxB 0idQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722351754; x=1722956554; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2aHnBGDy68xwYXXDjrfSbMfL0AOPRRbHUN6FtVmc8lU=; b=r2YRTk7BEhyrjhtsKtiswWRbMr6TDXP+Ex6iGJxxfE4VlewPVTHtwJlMpzd5ClKEiN CYuyBUYc6LfVHl8GAuF6uCyL+iO/TESTMw9DFbdUS/ug1WVvup38ogUb4idm5Tik3vaZ MtJguL3WqN1O2LBLC9dTyBrSkrq8g/ZJuc/7cCm/0lL+s8B+OVOFYYUW1BzfuQXXRu0k 18T5SseWEbcn7Q42BpMC9xIC7J6Z46R7Yo8gY/7rUPqVPiYvi6/eq++peUhhzBzw37jh hiDy7nnE8TE4UkGV6YhcCs/VsbqC20OlsXJxxvcl7RTFNOnZR8qZfQENutB/hGOYCpCE mK9g== X-Forwarded-Encrypted: i=1; AJvYcCVTqsk4rE8NwlWNGPvvy4MdYBPGHtCtmb5Mk2ARWEQt+OxBUWrLutvpo1IacUgtlI6/Txqf9v9TOU1eqpALJYtbwRQ= X-Gm-Message-State: AOJu0Yzw33CKpaUi+gdm/urbHyU0oyfiGSPcg399tW8h5p/YkcK7EaL+ jtl/w3xggYdHYSYnoaiEUjEI4jft/+ABne2/25VXWrmiQvM7lP6bZVpfWkfZPXU= X-Google-Smtp-Source: AGHT+IFxLC8+/Z/VDyAUb7tf0WUqsksRLJR+UaYeagUb+QXKem8cCoH3WlCYwUUUbTE/PYYdq//rKQ== X-Received: by 2002:a05:620a:269a:b0:7a1:d08d:e2fa with SMTP id af79cd13be357-7a1e5229e64mr1516298285a.1.1722351754104; Tue, 30 Jul 2024 08:02:34 -0700 (PDT) Received: from soleen.c.googlers.com.com (197.5.86.34.bc.googleusercontent.com. [34.86.5.197]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d73efffdsm645934285a.69.2024.07.30.08.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 08:02:33 -0700 (PDT) From: Pasha Tatashin To: akpm@linux-foundation.org, jpoimboe@kernel.org, pasha.tatashin@soleen.com, kent.overstreet@linux.dev, peterz@infradead.org, nphamcs@gmail.com, cerasuolodomenico@gmail.com, surenb@google.com, lizhijian@fujitsu.com, willy@infradead.org, shakeel.butt@linux.dev, vbabka@suse.cz, ziy@nvidia.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, yosryahmed@google.com Subject: [PATCH v6 3/3] task_stack: uninline stack_not_used Date: Tue, 30 Jul 2024 15:01:58 +0000 Message-ID: <20240730150158.832783-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.46.0.rc1.232.g9752f9e123-goog In-Reply-To: <20240730150158.832783-1-pasha.tatashin@soleen.com> References: <20240730150158.832783-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2B31018002E X-Stat-Signature: gp4nxdp113bk5q5keh7of6jdp49ce14c X-Rspam-User: X-HE-Tag: 1722351754-336399 X-HE-Meta: U2FsdGVkX18kwg0T/sjTt3KIKMIw/IW0P94ZHe9p4iC1d488VuQiCb/nabMVbS/l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iEoJzm3YsnPxESj+y5rMcj3LDwvIx8Cy39kENfWXXfjYYQ6nSaQMC7ZKbTI2WgnPJZWEy2yHmVl/B3rlF9/DHh1XQpY8TLHhDT/5loC1HOdLnyWyGjp37fABc7H9zALFOXyZud+NaBENoTJYC6tZJMvK0Qh61W0fAtO//XlfCVw3KwDBP1FJDPQKgjvkfLyC4zFhX1vdruIAXXcn6+TegeGQZFc1a9a6+rpOtueU1YoSjhjf3zBzzEJWMoxcE9Fuq1XI16m+i0DgT X-Bogosity: Ham, tests=bogofilter, spamicity=0.000004, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Given that stack_not_used() is not performance critical function uninline it. Signed-off-by: Pasha Tatashin Acked-by: Shakeel Butt --- include/linux/sched/task_stack.h | 18 +++--------------- kernel/exit.c | 19 +++++++++++++++++++ kernel/sched/core.c | 4 +--- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h index ccd72b978e1f..bf10bdb487dd 100644 --- a/include/linux/sched/task_stack.h +++ b/include/linux/sched/task_stack.h @@ -95,23 +95,11 @@ static inline int object_is_on_stack(const void *obj) extern void thread_stack_cache_init(void); #ifdef CONFIG_DEBUG_STACK_USAGE +unsigned long stack_not_used(struct task_struct *p); +#else static inline unsigned long stack_not_used(struct task_struct *p) { - unsigned long *n = end_of_stack(p); - - do { /* Skip over canary */ -# ifdef CONFIG_STACK_GROWSUP - n--; -# else - n++; -# endif - } while (!*n); - -# ifdef CONFIG_STACK_GROWSUP - return (unsigned long)end_of_stack(p) - (unsigned long)n; -# else - return (unsigned long)n - (unsigned long)end_of_stack(p); -# endif + return 0; } #endif extern void set_task_stack_end_magic(struct task_struct *tsk); diff --git a/kernel/exit.c b/kernel/exit.c index 64bfc2bae55b..45085a0e7c16 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -778,6 +778,25 @@ static void exit_notify(struct task_struct *tsk, int group_dead) } #ifdef CONFIG_DEBUG_STACK_USAGE +unsigned long stack_not_used(struct task_struct *p) +{ + unsigned long *n = end_of_stack(p); + + do { /* Skip over canary */ +# ifdef CONFIG_STACK_GROWSUP + n--; +# else + n++; +# endif + } while (!*n); + +# ifdef CONFIG_STACK_GROWSUP + return (unsigned long)end_of_stack(p) - (unsigned long)n; +# else + return (unsigned long)n - (unsigned long)end_of_stack(p); +# endif +} + /* Count the maximum pages reached in kernel stacks */ static inline void kstack_histogram(unsigned long used_stack) { diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a9f655025607..b275f4f27e3c 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -7405,7 +7405,7 @@ EXPORT_SYMBOL(io_schedule); void sched_show_task(struct task_struct *p) { - unsigned long free = 0; + unsigned long free; int ppid; if (!try_get_task_stack(p)) @@ -7415,9 +7415,7 @@ void sched_show_task(struct task_struct *p) if (task_is_running(p)) pr_cont(" running task "); -#ifdef CONFIG_DEBUG_STACK_USAGE free = stack_not_used(p); -#endif ppid = 0; rcu_read_lock(); if (pid_alive(p))