From patchwork Wed Jul 24 20:33:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 13741345 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 17FABC3DA61 for ; Wed, 24 Jul 2024 20:33:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA4C86B0093; Wed, 24 Jul 2024 16:33:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B31976B0095; Wed, 24 Jul 2024 16:33:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9A6DF6B0096; Wed, 24 Jul 2024 16:33:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7DA236B0093 for ; Wed, 24 Jul 2024 16:33:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3A204C0C16 for ; Wed, 24 Jul 2024 20:33:31 +0000 (UTC) X-FDA: 82375796622.23.3A77AF8 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) by imf02.hostedemail.com (Postfix) with ESMTP id 671718001D for ; Wed, 24 Jul 2024 20:33:29 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=zAgAwmWS; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf02.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.169 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721853170; a=rsa-sha256; cv=none; b=Pf2DHON8vwARGVMy26qbCjttJ+n3MD9mxYwCyHq4SeK67rH/dDf/ryG3IszeYVSjRsN6bo p16GigTJCyUcOwcAjFaJBeTypWid74OFVv6pQIA/lYxMyf0yrfDGKVdM2KGz7Zggyes3kl YfpNjTjcWPqTGHy26VXZPJlXqtHtrDk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=soleen-com.20230601.gappssmtp.com header.s=20230601 header.b=zAgAwmWS; dmarc=pass (policy=none) header.from=soleen.com; spf=pass (imf02.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.169 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=1721853170; 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=EKGazB9ClhJRcAnoyFkGgUjUokS0gyXTYpAGog1A94A=; b=NSF4cVRws3h10SQptRac4JdjVUG2jyDbVblfi2/8waxsJtBM5dAVEWnvZmHB/K8Lk9JOq0 Y3zrteIv6rOPQuX4uJVbn3bQBwu/wYEMZNSQ/NTe2knt8kpuJus1puhojtmg7XaDsYIVAs xjZdH+KgUXCgs5xtPGSzME/kYo0I3Tc= Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-79f323f084eso9238085a.3 for ; Wed, 24 Jul 2024 13:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen-com.20230601.gappssmtp.com; s=20230601; t=1721853208; x=1722458008; 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=EKGazB9ClhJRcAnoyFkGgUjUokS0gyXTYpAGog1A94A=; b=zAgAwmWSU1kM7X3hssM0ieJKN1tCK1XYXpevcWGX3tX+jNL9lLrw40vgqC9UW1MuDa a6R+ZA/bIAVavyQATIM1KFz2IPS0G8MiSog1IwwTzAhBwzvvd2c0tZW9f1jStRrwPdjQ v4WP7jljTbdGpDGzronPVxPfkFyG4bCVv2MJXBMXcpL9xyCHFZw5iTDi5nCsUOSl2aRb T8KVwipZkGYWhvEIVfSsg3Y4YODCgenfCNP2IKk+rMp2jj7P4YtAEaZKmGPwI1jcuLOC CHHCeqgqBesIUIEOArC8PTxG0Hd8+oLUvedIkl1aZNx3Li2mCNOX3km8UtdeEoidfVBi gmmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721853208; x=1722458008; 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=EKGazB9ClhJRcAnoyFkGgUjUokS0gyXTYpAGog1A94A=; b=sv4E/aDQJLNDYNq/AgIvIeDDaKB7m/P+ZuD8uk4NHzTMaXI6CVhWbCjQSYgobxjywo 9ho/kPqhdcsy0erNJtl90YnYu85CxhB98LiEL/2s46/vuh8pMwXMAe+pPC2j60X+BjMC WBrr4Lk4sNNGYXuv+cbAn8GNbV5AcNiQGtX3zbJat41xTbyP4I3Q1roBuGFnF96rNHYL 77aDpsOscxE4b8WACaEwqplAZvlbi7DxZNMwHuKupua797qGf5GVqcFGGeKDszCvVCJw 3WmMUMFe4/xQZ3UXHuebxLDGRpUaG02bPQmUrIQAP4b+FJ40pxU9JTBHWVnuBw06mzTl RGXw== X-Forwarded-Encrypted: i=1; AJvYcCV6J/QQzSj/T9+ZHRB98t9jmCZTwOwRnI+liJWhq19FYBkZ/DavyzpMgXI8thS7kfAvq6RxPi5ani9VbYi9KavaiK8= X-Gm-Message-State: AOJu0YwZ2UDaX7qVSzUxgnQfAAWqjXtipog1mFyIP9P3+wW7Waaq7NwE +I1hFHYs8UlI4ERNVBCGcYOO2gMKYNjienvKk5HPxTfu4LywIwQCdOKX+bhvV+Y= X-Google-Smtp-Source: AGHT+IGdbA77q0Ryd5vfCl/zff1MduhOE0tjAnp/J35IRonbXQFsuFvYQZxmL8WXYNZns3Wr9gC6Dg== X-Received: by 2002:a05:620a:40d3:b0:79f:17a8:b83 with SMTP id af79cd13be357-7a1d45850b0mr104907085a.33.1721853208537; Wed, 24 Jul 2024 13:33:28 -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-7a1d73b1786sm466485a.33.2024.07.24.13.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 13:33:28 -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 Subject: [PATCH v5 3/3] task_stack: uninline stack_not_used Date: Wed, 24 Jul 2024 20:33:22 +0000 Message-ID: <20240724203322.2765486-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.45.2.1089.g2a221341d9-goog In-Reply-To: <20240724203322.2765486-1-pasha.tatashin@soleen.com> References: <20240724203322.2765486-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 671718001D X-Stat-Signature: 5q54eeumoqjyii7g9mggiy33wrhzdhpo X-Rspam-User: X-HE-Tag: 1721853209-380999 X-HE-Meta: U2FsdGVkX180fx5lccIb6R5DkEPdivlug/erNvpH5O2my8G2Hp2FndYC+A4g980Ag79tKSAKKBUlq+cpiZQRPHa+dBvrj7Whj0TcIN5xjGb03vaHvOD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KYvgNAIblurkpbYxrJXzDSA5uDhkzkOh200D0y621CXPKreYQeE5Ta68sEyrcWLhuM6T831afuOr557l28Fp40jfIoGLmKrfBQwX8Pd5iorfJOm3D2CqrVgPcT3apd7ydKvxQkQobt+65JdWPLKwe02K1ccPLubp6wZq0vwnFxcnKv+E/bZ2RHtSvf/T6L2hb1h1OuylQSVTKnn0bj0s4Ih X-Bogosity: Ham, tests=bogofilter, spamicity=0.000022, 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 ae5ef3013a55..f5861f64e960 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))