From patchwork Tue Dec 27 03:08:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kirill A. Shutemov" X-Patchwork-Id: 13082046 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 18C83C4708D for ; Tue, 27 Dec 2022 03:08:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F167A8E0008; Mon, 26 Dec 2022 22:08:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D89368E000A; Mon, 26 Dec 2022 22:08:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9956D8E0005; Mon, 26 Dec 2022 22:08:55 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7E8C98E0008 for ; Mon, 26 Dec 2022 22:08:55 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4F2101A048A for ; Tue, 27 Dec 2022 03:08:55 +0000 (UTC) X-FDA: 80286604230.03.71AC4B0 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf19.hostedemail.com (Postfix) with ESMTP id 5CD7E1A000D for ; Tue, 27 Dec 2022 03:08:53 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=LHO+dDcX; spf=none (imf19.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.151) 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=1672110533; a=rsa-sha256; cv=none; b=LjjcBfM2D64PQS5P6XXZkKhTBgwvE7yMSq1tRKDhZxqs/4GzoixIozjc8HGEesHhy1hIeR csepMGFtcZswuK6m6r4s8Tb2MenH9D7oiGuCSM4G1YOR8TseM/cALCp2i0pBG0NhBQTNWB GXcq9p5Iuvp7z19Nk/QgWIfuhZ/Bx1E= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=LHO+dDcX; spf=none (imf19.hostedemail.com: domain of kirill.shutemov@linux.intel.com has no SPF policy when checking 192.55.52.151) 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=1672110533; 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=IZoWeD42yWh9XTUsLlcRaLNhHxRpiWGm/Bt6fqyV4JE=; b=sJxzE9GJHVJvMSn1t8y8B0WejoiHUuo8U0UVo8UhEq0PaGgkiICWKB2byxvd1pbddyhL3T QCjNj3F+5wp05oA6CSBMfOFQ/GOOJJXBvTmBSwr7kc+zuVLJkt85IL/SqAJK5o08hiji+/ 2aPnAe5Cb2gOlC7x0SDvPKAYlAD5veY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672110533; x=1703646533; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2hNvtI+I64q9AU5Zc+yHHwHftID1PyaOfc87+zaI4fg=; b=LHO+dDcXatztMn1YGE7pnDsrkClBvGfi/59YqBy3Ys0nqhF6EEM6QWY4 w5frZNIumIqecwqq6Fxl+4q717sO55k1qAona/RMKXQyi0RT+/eZDrj8q 0zXSANZqmHbnRGTGyniZc4vkJxS7chaAu1rl4IVGhumCN3PUbMXY9KxVy xN1hVadrK7P1NSbG4VV6a3OoW5bUriQVFP0vYJWpHf66/+os+orqGh9/g 12YIjyvAWQAAYqg1VAO0LA7lZW6VxIEOiGFG2VJm5njhRPBAZwl8kE64Q ZSnM+rkm313AQwdIO8n+rnkrSzz2bTAiwcEy95Mcp+1tSwYbP13KmgJCz g==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="300994707" X-IronPort-AV: E=Sophos;i="5.96,277,1665471600"; d="scan'208";a="300994707" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Dec 2022 19:08:50 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="741605219" X-IronPort-AV: E=Sophos;i="5.96,277,1665471600"; d="scan'208";a="741605219" Received: from ppogotov-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.62.152]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Dec 2022 19:08:46 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id C95CE10BBB5; Tue, 27 Dec 2022 06:08:36 +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: [PATCHv13 08/16] mm: Expose untagging mask in /proc/$PID/status Date: Tue, 27 Dec 2022 06:08:21 +0300 Message-Id: <20221227030829.12508-9-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20221227030829.12508-1-kirill.shutemov@linux.intel.com> References: <20221227030829.12508-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 5CD7E1A000D X-Rspamd-Server: rspam01 X-Stat-Signature: 8m6br75cywjsrcj9csxo3yntctgrzhe9 X-HE-Tag: 1672110533-575663 X-HE-Meta: U2FsdGVkX191cSjRqgwuLXhoWRixoEWIH8EIJbHeYeWV0y0TBXzCyPhg3W9ipZQhpZbbTk7B/mIhrSPECEn2Rltl/uVgdsI71F4Z21qxykiDPamyw8vRUAsl3sND/ZsDNMCWB5Qf4Qzqwv8hjrnM+7VyW9afeZEyI2cGW+W0diEALGhE8nfuHZ1C0Isk28uK2PJdVoXwaSjoPC33fcix8Ypzq7tHESUQhgm6zw3W06EF0bQZ22ydmvCYl1CZ6+KnJLsHYlzIaAw4F7GTF7K7PovW3a5OGec6br+F9S/lEnSm83iK5oWEBrT48UjrEyBfP5U9S+n6iTGD96MvvcO1tSIdbKAj4Rz1Q1DPp9HmZOF7qkutjtHg8yHDAgAb58tLVTvpDQoG76TUUu0iN22DRWgtqDRl/7ChAb4zgvIhiCVHuVvTT3DLnWGxdnn6XsaYlAduruknP/F5ziSaFIBdTKx5yTgIAnDPbTgVGQDPs9n7Q2XeU7bsBk7exc+nuV9bzXH8yaohctvhaX5NStlVgvqPEf83pdznNxKF976Debfc0GtfP2+cVMeI64qQOJaDYFhnESlmOO+hnWWqdJRG/6eZWPGkBEEGEhJmQ5BIBHaoTySjTxyhVghQ7z1MwaxIBZhHgYuYCzvYRcKuB27BQ/HD9VoUA0WfiTtGBFleSalOtHlZqXNhLNTDpR2YQucxyYTy/nLTjuVbe/+SLLG4Nbj9Z7VbScUu3TDfgor8nHRz5iX4mp9QYsG+ZEbKulX1KYbgpk4pHXO0zjVxy1ct1cTxk2wgn+VvVQJ4ekcj9Yuxo15pHuhmgWXrGhJhTccE2tH4dBJSaC8o5dcQ+Dlg1LADqfQc0mM/skI+iDut6KQo9E/9oMhzLjmZCrhCNDlboRwvmkf4qsfUTogT5FiMvFrISZurkL1UHnpklEXRg/XMinL6Po4dBeFAjnEtofbdoZ0pOcNSAfLsM/30rZ3 ayjhRG5+ GSjjl9+73gjjgzALWZjZGYC68tQ== 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 --- 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 71581cb4811b..7f9f9978c811 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