From mboxrd@z Thu Jan 1 00:00:00 1970 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 24925C3DA5D for ; Fri, 19 Jul 2024 22:05:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E7E56B0083; Fri, 19 Jul 2024 18:05:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 797CC6B0085; Fri, 19 Jul 2024 18:05:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65F456B0088; Fri, 19 Jul 2024 18:05:01 -0400 (EDT) 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 466A16B0083 for ; Fri, 19 Jul 2024 18:05:01 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E69D21C18B7 for ; Fri, 19 Jul 2024 22:05:00 +0000 (UTC) X-FDA: 82357883160.29.AE8A606 Received: from out-172.mta1.migadu.com (out-172.mta1.migadu.com [95.215.58.172]) by imf13.hostedemail.com (Postfix) with ESMTP id 24B8920002 for ; Fri, 19 Jul 2024 22:04:57 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Xs3sqVP7; spf=pass (imf13.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.172 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721426655; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=eFYBCysMktN44xqqHXD2HgYrB33axzEkhlU1r9cNdhU=; b=MNGeWkdkIgNT8S8EVC2YKjEgTlBycmdWOVsA20ix8ZaCyxWdw80U0Kolqag2JcMF81/xaK xy8Jetj/z5YwUlgssmEkRhQoSM4UipS3bgiMGHVmXBBH1H1Qw3CG75LF2YWs4wBPELMSwz 4I3dl26BWu2auFDrlJ+8ItKE/BZ47eA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721426655; a=rsa-sha256; cv=none; b=og1jxVwYs0Wj24oddPdn8bVu8rQMIAl2BvDxtE2nWhD0VNVAqZD/Gm5y/qwr2GwdcQwVDc /lbeZDClV3HP0PkD910WvoQbQimsTCFD07+VlkEqJRnz25ZuH7WBTvFP5SayCtMnHw2HUo Cy3AxDb6nS6DOn04/Vg9gLA1tbXjwro= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=Xs3sqVP7; spf=pass (imf13.hostedemail.com: domain of shakeel.butt@linux.dev designates 95.215.58.172 as permitted sender) smtp.mailfrom=shakeel.butt@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Envelope-To: pasha.tatashin@soleen.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1721426695; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eFYBCysMktN44xqqHXD2HgYrB33axzEkhlU1r9cNdhU=; b=Xs3sqVP7knzwsj8riTanFOj+iXGIURj5hv7DMssgxlexRorRu8eiexkf8UFoRP3yKbcAMf KtafKxcWm8OhyCLNPXHp3idWSPpbfUPM8nE1cHOiiAF4cZv/lFBj3GDW9lDjTcdryYUj2Z JJNt8Ll9dwalECmxFMqLk8Y9OEYivWw= X-Envelope-To: akpm@linux-foundation.org X-Envelope-To: jpoimboe@kernel.org X-Envelope-To: kent.overstreet@linux.dev X-Envelope-To: peterz@infradead.org X-Envelope-To: nphamcs@gmail.com X-Envelope-To: cerasuolodomenico@gmail.com X-Envelope-To: surenb@google.com X-Envelope-To: lizhijian@fujitsu.com X-Envelope-To: willy@infradead.org X-Envelope-To: vbabka@suse.cz X-Envelope-To: ziy@nvidia.com X-Envelope-To: linux-kernel@vger.kernel.org X-Envelope-To: linux-mm@kvack.org Date: Fri, 19 Jul 2024 15:04:40 -0700 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Shakeel Butt To: Pasha Tatashin Cc: akpm@linux-foundation.org, jpoimboe@kernel.org, kent.overstreet@linux.dev, peterz@infradead.org, nphamcs@gmail.com, cerasuolodomenico@gmail.com, surenb@google.com, lizhijian@fujitsu.com, willy@infradead.org, vbabka@suse.cz, ziy@nvidia.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v4] vmstat: Kernel stack usage histogram Message-ID: References: <20240718202611.1695164-1-pasha.tatashin@soleen.com> <2fbbxcsjs7vtzpb6a5wudbppcr2wgc2xwdw3cgs6ejzx6rioze@z2sct6rbulng> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Stat-Signature: 4p9qszsihq1xthzicukewt4aarcnnijd X-Rspamd-Queue-Id: 24B8920002 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1721426697-529941 X-HE-Meta: U2FsdGVkX184dthm5mVuTA/k/KOFMHlqQ8+OgSlcgob+wdaueO8+oXifPI1l6Nah2ZwLXITrROGZO6HH6s0VvYZLzOqoTcIg//ZAo2y818Hkg92FPUG4oyMuRUfvTLL6kEFtE5aGPblZX/fUzCc6kVLOFO2XA11U26B+THArFe9Ch3h4Q6FxgSNW3Eu7SiYvpatIu9ffVzteKg2RR4ebCZw0+LFCPh7dzybWi0Nhi+kwTa7HJkXB9pPaciEP5+AtpRZkL/7w3SgjUi9VNQdfQ7M+xrRHdTN47ecP6nfMb+xI85UsfgUsW7P9RhPH8BXRTc2xd8z3sC7iXj7Fbbms7oubaaQy92qnl0KOoLWZuTITTvCvfck87R/K7WbaAGB/cE85RLnR/wjZRKCTbt7par7jW3GUk9yJKnufHlsLoeSHtA2aly56kV0a65R2a1beUppJb9dgITx5gGvUQaUjlbEKQT7Un0cOzHC3U/IMDTeReD/5b3gcE2dkCs17hdYgv1w2lOteyiOGbZY9Z/s9Vh6hdzAcSWe6P6O9xWeu+mqVrgBlDMvqHOayjvOi/o6+Yax8eyPd0vnBaMDYje1lv3ujXA+SfyHbRdPHQgcHybOMpi4Qjur4SajdhlReRWhkYQO84czeENyVQYUYPGLUuiFsRJnhP/l+8d/2DsdrCKMTgPVsrauwzglBAzwgcO1IFBUMxHMuPGypBIOzLV3X0rrmG8LUu/QDiAXpIfBUOHpEvKzxrQPNS9t5Xk8DkVt3PpQUOjiszQwsisiAa6DEHeX+m21MpcadJhUHrzMh4rCp0gROUFu51JwIBwd1CVKnVtRJGDe9M9EH+lbVDILu9sibdl8p2jYrI0dSbPUxYbJg0TCexcqi9GvdMPMtP/y5J9SASwpO1QvfJBEGSdwvqyiIQnUaBhH8xoObZXajkWWAELD8Tl9biS/lKfkw/ytOPKF0ye6eBU/a5p2D6mY B2IXhxrS ughDbyPre2l0u1rSr3WNef0hpy8zzieRiECBI5F/8FFXXkHNHwyzwlIylNTdRAvs+4PjEnZUjP9HmMoLaP7GLQNjcEfbvBW2enZJDDw5mvVcIPJzqXC4C2ACys33DFEqQsWv5R2lJzrssCMkR3pVyylIHtQ== 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: On Thu, Jul 18, 2024 at 10:55:17PM GMT, Pasha Tatashin wrote: > On Thu, Jul 18, 2024 at 7:36 PM Shakeel Butt wrote: > > > > On Thu, Jul 18, 2024 at 08:26:11PM GMT, Pasha Tatashin wrote: > > [...] > > > diff --git a/include/linux/sched/task_stack.h b/include/linux/sched/task_stack.h > > > index ccd72b978e1f..65e8c9fb7f9b 100644 > > > --- a/include/linux/sched/task_stack.h > > > +++ b/include/linux/sched/task_stack.h > > > @@ -95,9 +95,51 @@ static inline int object_is_on_stack(const void *obj) > > > extern void thread_stack_cache_init(void); > > > > > > #ifdef CONFIG_DEBUG_STACK_USAGE > > > +#ifdef CONFIG_VM_EVENT_COUNTERS > > > +#include > > > + > > > +/* Count the maximum pages reached in kernel stacks */ > > > +static inline void kstack_histogram(unsigned long used_stack) > > > > Any specific reason to add this function in header? > > For performance reasons to keep it inlined into stack_not_used() which > is also defined as inline function in this header. > Is this really that performance critical? > > > > > +{ > > > + if (used_stack <= 1024) > > > + this_cpu_inc(vm_event_states.event[KSTACK_1K]); > > > > Why not count_vm_event(KSTACK_1K)? Avoiding header include recursion? > > I could not include "linux/vmstat.h" into "linux/sched/task_stack.h" > because it introduces some dependencies such linux/mm.h and > linux/fs.h, uapi/linux/stat.h, and when all of those are added it > still fails to compile on some architectures, so it was just simpler > to stop resolving the conflicts and use this_cpu_inc() directly. > The above makes me think it is better to move stack_not_used() and the new function to C file unless we can show the negative performance impact. I have another question. At the moment, the metrics are exposed conditionally through procfs based on stack size. So, based on the kernel config someone may not see kstack_16k. Why not just output all of these metrics irrespective of the config? Shakeel