From patchwork Mon Jan 23 22:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 13113089 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 4D5B6C54EAA for ; Mon, 23 Jan 2023 22:05:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 607176B009F; Mon, 23 Jan 2023 17:05:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B79B6B00A0; Mon, 23 Jan 2023 17:05:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 430136B00A1; Mon, 23 Jan 2023 17:05:42 -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 2C7F76B009F for ; Mon, 23 Jan 2023 17:05:42 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E444A1C5F9E for ; Mon, 23 Jan 2023 22:05:41 +0000 (UTC) X-FDA: 80387446482.26.440CD23 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by imf29.hostedemail.com (Postfix) with ESMTP id C80B8120019 for ; Mon, 23 Jan 2023 22:05:38 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=UoUk+Ysd; spf=none (imf29.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.115) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1674511539; 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=EFiuqEF1AJ35Zpy8Sw/UigXH2q9I0vE41W1sxgJG5sg=; b=l0NomFcMAv8L0vJKZ0YKImWHOL00mykuSOQ9N93IyoOxBIarKjG6+5QUzF9YgKd8tS+3uw 5FYoOWdXsClnBlabuxooFQYRfkN8LBybKRe+cFmVXdPv1SnEGgQyvnTiMWUdGSRpumNHp3 VTWGN2sq+DwyISuhGSE92p//X+6rbIM= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=UoUk+Ysd; spf=none (imf29.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.115) smtp.mailfrom=kirill.shutemov@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1674511539; a=rsa-sha256; cv=none; b=eG28UZMFPBHy6fyPkyB3yJ2ecuzm3bgdEDHf+6BkYOzvjjZ9Ft/wkTfwgWIAJeKc/dhFSu Mu2NQ/27CfqDOReyciUAQJWUDkLVB11HuyTw75G+sT9i4n5upmpqlyGanIxUEDAfxql2RO x1TKAuOljOQosV0DoeQ0VwQ7Xcy2/6Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674511538; x=1706047538; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OVB8ixW2SlvKXCjvUsAuiBNx4ctXMcDQHlcvi2JSoRw=; b=UoUk+YsdIxqD16N7TNqzn9+0oulByMuLWztWBh+crUdCgicx0OYh1fmL dKMh5B2Vq8E/oD24LoT8VGIrkNpfRm4jJvBO0/2tlu7L7r4bJgPbWmW1/ HRC8YMKSDZmscKvp1IKcy9K6YKNcW4dreF/F7bIeZbG2QiLOqWZOPMO7A 30rZR2DyoGdd2tONf7CHlPLCpOdIhcuvlqp/tzCaNReXB1hAkeymlU4H1 hKmLa2MNy8zx1DuNXhHij3MZtz+RIZMZovTHljmJOGFrCCy6faJYv7zPP SmHyhZN/EZB0V1kik/jFlK1KeHIZJhaTaHguIpNJ2+zKLztDrT0ZgR2bj g==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="326198215" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="326198215" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 14:05:25 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="694103441" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="694103441" Received: from ssauty-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.46.171]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 14:05:17 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 79A2B10947A; Tue, 24 Jan 2023 01:05:03 +0300 (+03) From: "Kirill A. Shutemov" To: Dave Hansen , Andy Lutomirski , Peter Zijlstra Cc: x86@kernel.org, Kostya Serebryany , Andrey Ryabinin , Andrey Konovalov , Alexander Potapenko , Taras Madan , Dmitry Vyukov , "H . J . Lu" , Andi Kleen , Rick Edgecombe , Bharata B Rao , Jacob Pan , Ashok Raj , Linus Torvalds , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Catalin Marinas Subject: [PATCHv15 09/17] mm: Expose untagging mask in /proc/$PID/status Date: Tue, 24 Jan 2023 01:04:52 +0300 Message-Id: <20230123220500.21077-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230123220500.21077-1-kirill.shutemov@linux.intel.com> References: <20230123220500.21077-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C80B8120019 X-Stat-Signature: i39enhfcqudwik8wkwsjftbk4m51i951 X-Rspam-User: X-HE-Tag: 1674511538-136530 X-HE-Meta: U2FsdGVkX19acL4ocnSzf9hoAopyHwf6tTXSq8anT5g+cCXJiLz0xUHHuMoQFUc9l3RU94wzdNUYicJd9VLqqpBObgTmxOPbCIk/px3hAmdETCX5z3GGv/SZZ4CjtTETkN58coGbngsXmCG+KuIJ8BU795YergNwzKsdH8EYpgikYawRRLStQVlgSOAouaJFL8JoLmJqfYv96uHGo04L7zFTwbH2qwmKUHnDc0yd7hl61Lpn+yIG/mdSalHhAKDA+j+0P/isHoasKoSA1luxyC/LGdwvqeeM6NQRzE2WLAAUgX+gAjl85Ndv3gFTsdQlaOSfvBZdJ7HWBbK4rLrPtrLRPKeuwCqSjNAst/9u0zWDMFiZ8vnqqyRIAmnKf6gpaW4e7eGizSetYYxEpRcZkfSYnc8p+EZJamE2S4Fe/yg0w0mbXLRYkmauImubsgMo6ndFZMHlqLsJ7Gpni+VyL14S81K4V56D1LMqa7sfAZVuLAkhxlcXxap4+2AknX26aoiRROr9s2ymE8ow08ElsBCciZ/3DWAVJ3m5gjGkL/MUW2xn15GM5Cfgh/vxiIE1+z/wru7KqBOQq43HXsvhhWiqrwCU8+vheSxXd4VzajotEkHhVjW/G/N37wcUZ2Y8RG9q/5BbOpDwfzcn55mODktEjzT8Vif6phBeaezcVISXRpSG9cDKJGX85Syn/CtsmWNzZfSypaezkxlxnA0eswiabn33vHHjt1azAhJePPvNI8T1anmVigXW/LxDsQl0P2kxWZZx8pSbOWXXJwooW7O7+fQaKi8MOuyLfZDYwKHgMtOFmUm3yaCM/BekSwqrBw5jl9j0ogjO0lS8/lQpy2rL2KRiQTYAMoZi7vAxOBWZkWV/YlQjm6CM03vkIemqayxK0i33Hm87hvyjHEPu5c/eBS/2AD4TPLXLnDrx7+ThVvHir+FjpbxSCNXhAdNjwiWqgn3NbtErujnertb f6a8iZLj lHBVtawFm29eURm/Ql//QH2VizwLY5cdbq+cyGGryO4w+bDV5fAgOLPa3foRyQJnBAMIXtk+M+QlqjGUt+YFpo+j7OpND10bVC8Ia5K0luoiQjRLsJXeN4gLYgMi/bxPXGnIX1ZsHF59CkVfOswQuDgFnn5yihDA6kze114PQXCCOfyff2k08Tu132foj2i3GnqI76OANwhJRjb/S0rAZrr5dlU01Zu5da7N4Zy0juqt3FMEru7rjyGGOpIdQZKWfB2WrXkCxSdLeKS7aVR5HFHQdwtX7fy0l44NpWOuUTMnUtTiq29PY4nd9Rkitw87mKnGVaoiImB6DQs+Mhkz7izOcTGsulzwR0l4zs0Cx0MgdNNP10EOBgw3VriSXEMfIJdTcOWpgU+A2EuQ= 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: Add a line in /proc/$PID/status to report untag_mask. It can be used to find out LAM status of the process from the outside. It is useful for debuggers. Signed-off-by: Kirill A. Shutemov Acked-by: Catalin Marinas Acked-by: Peter Zijlstra (Intel) Tested-by: Alexander Potapenko --- arch/arm64/include/asm/mmu_context.h | 6 ++++++ arch/sparc/include/asm/mmu_context_64.h | 6 ++++++ arch/x86/include/asm/mmu_context.h | 6 ++++++ fs/proc/array.c | 6 ++++++ include/linux/mmu_context.h | 7 +++++++ 5 files changed, 31 insertions(+) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 72dbd6400549..56911691bef0 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -288,6 +288,12 @@ void post_ttbr_update_workaround(void); unsigned long arm64_mm_context_get(struct mm_struct *mm); void arm64_mm_context_put(struct mm_struct *mm); +#define mm_untag_mask mm_untag_mask +static inline unsigned long mm_untag_mask(struct mm_struct *mm) +{ + return -1UL >> 8; +} + #include #endif /* !__ASSEMBLY__ */ diff --git a/arch/sparc/include/asm/mmu_context_64.h b/arch/sparc/include/asm/mmu_context_64.h index 7a8380c63aab..799e797c5cdd 100644 --- a/arch/sparc/include/asm/mmu_context_64.h +++ b/arch/sparc/include/asm/mmu_context_64.h @@ -185,6 +185,12 @@ static inline void finish_arch_post_lock_switch(void) } } +#define mm_untag_mask mm_untag_mask +static inline unsigned long mm_untag_mask(struct mm_struct *mm) +{ + return -1UL >> adi_nbits(); +} + #include #endif /* !(__ASSEMBLY__) */ diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h index ca2e2ffdd3c6..43eb6b1357dd 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -103,6 +103,12 @@ static inline void dup_lam(struct mm_struct *oldmm, struct mm_struct *mm) mm->context.untag_mask = oldmm->context.untag_mask; } +#define mm_untag_mask mm_untag_mask +static inline unsigned long mm_untag_mask(struct mm_struct *mm) +{ + return mm->context.untag_mask; +} + static inline void mm_reset_untag_mask(struct mm_struct *mm) { mm->context.untag_mask = -1UL; diff --git a/fs/proc/array.c b/fs/proc/array.c index 49283b8103c7..d2a94eafe9a3 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -428,6 +428,11 @@ static inline void task_thp_status(struct seq_file *m, struct mm_struct *mm) seq_printf(m, "THP_enabled:\t%d\n", thp_enabled); } +static inline void task_untag_mask(struct seq_file *m, struct mm_struct *mm) +{ + seq_printf(m, "untag_mask:\t%#lx\n", mm_untag_mask(mm)); +} + int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, struct pid *pid, struct task_struct *task) { @@ -443,6 +448,7 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns, task_mem(m, mm); task_core_dumping(m, task); task_thp_status(m, mm); + task_untag_mask(m, mm); mmput(mm); } task_sig(m, task); diff --git a/include/linux/mmu_context.h b/include/linux/mmu_context.h index b9b970f7ab45..14b9c1fa05c4 100644 --- a/include/linux/mmu_context.h +++ b/include/linux/mmu_context.h @@ -28,4 +28,11 @@ static inline void leave_mm(int cpu) { } # define task_cpu_possible(cpu, p) cpumask_test_cpu((cpu), task_cpu_possible_mask(p)) #endif +#ifndef mm_untag_mask +static inline unsigned long mm_untag_mask(struct mm_struct *mm) +{ + return -1UL; +} +#endif + #endif