From patchwork Wed Jan 11 12:37:28 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: 41998 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3319667wrt; Wed, 11 Jan 2023 05:28:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXt4auMoUbcXsNFBo9oC6Dqsxrdr0PflsmMSjACS4LA1ugDvsNmwUJ4/w2IYKjnwWuT7RF87 X-Received: by 2002:a17:902:b18b:b0:192:6198:a51b with SMTP id s11-20020a170902b18b00b001926198a51bmr65558491plr.20.1673443710421; Wed, 11 Jan 2023 05:28:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673443710; cv=none; d=google.com; s=arc-20160816; b=cL4b80w8ZmPMeXywXrH8wh8QW6sLFAglGqq4DpDeSOW2FZodHJxtBR1BVKYbNtVkl7 SxmhuNrVAXvB10AUFqvoAzGxR3HpNeNv8YX20VI0NF9+GIfwhPIpyZEEu+jyqoGJLeGZ fHmMZCwZ9uyNHZXpoCgn+YvtOhnWcbMGYqIYkyFmBMuCxrE9B+GEEe30UFSy0BsF02yO iSolzLmUXVONwMATns/xXKvfY3rJWY0SecVcz/F+OeWjeTplTlKKJuJ44W7vH5kq4VdZ v1DbnQOm7ROQ3nKS3rhepbbFoBgRYU8qJXIe4E1bIBvWcok9KnlYSN2CcUlXlOZEamQ4 5PCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=JWhcpMTBZsFYvhyMDa+qvhTJQCJxY9DKtAeneQshjaY=; b=QN0JNnyFMpr7i2MorXA/XUdR0xRHlZo9Muto4MdCIBMekcEHi0Qj+tE4P2j5jOziIj cB1hdglcggyfSwenMXyI1WQZ/Fp+JKEwqthcf4qPoNyPLuhy1vWzXFn/CYtKf3aRWdCG FDqP5Z4t75DevwS0qMKHyhy1LaVyEUxdIUc24o1Q9IeXBhUQ3/oujXL251hhpcxbDhNS 91bnQwLuRF4kLieJYWK61ulpFS3QE0TpItwWmylAmO+sKK5t4gABLPwP8t579kEvxsaf k0jsMSbR3i1ePQBOHjGTTzjVjok6UYYgPrO2oQ+s9Ka2wyAN8rj35Yd5WOtIyoF0e/rm 91FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AVpoSwX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c17-20020a170903235100b00192ff55301csi14671298plh.519.2023.01.11.05.28.17; Wed, 11 Jan 2023 05:28:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=AVpoSwX0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238303AbjAKNZt (ORCPT + 99 others); Wed, 11 Jan 2023 08:25:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234269AbjAKNYE (ORCPT ); Wed, 11 Jan 2023 08:24:04 -0500 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A32C3883 for ; Wed, 11 Jan 2023 05:24:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1673443443; x=1704979443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kszyd7Hv0tB7dUw4wLUAy/XS4ksOrmCTMURWZ8B+Snc=; b=AVpoSwX0IuU7AN2fypET9xIzUc6PvYi9UcRlmdGGiyfCrREaesuDdWbE DVN4NR7nLJlDro3/R3lXFu4InN1BjGcmar2yS1aFwfLVxO9Xqtkma3e+F qXrUNgut5xz6ZMUuETP4MAbphLhYsm5UOj21m2mUbVK69Va18ShutJvqP zlDIHWVIdib0IL82hBZD0dTnNb8rKmjLGwsd7jZq152c6ay2IMIAhAgby +Hso9nFq2J2/HDB1tNbV0K6e9XcdtnT8ROUcRD7UknygG2oiUw7wI5XHO FEnoRgzhxvZIm3ZPcIoSwUxGsNLMb5/6Z9vyd0hkLckSricV04RyJgGQl A==; X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="387872557" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="387872557" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2023 05:24:02 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10586"; a="687927441" X-IronPort-AV: E=Sophos;i="5.96,317,1665471600"; d="scan'208";a="687927441" Received: from bachaue1-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.252.37.250]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jan 2023 05:23:57 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 5F5FA109CB6; Wed, 11 Jan 2023 15:37:41 +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: [PATCHv14 09/17] mm: Expose untagging mask in /proc/$PID/status Date: Wed, 11 Jan 2023 15:37:28 +0300 Message-Id: <20230111123736.20025-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.2 In-Reply-To: <20230111123736.20025-1-kirill.shutemov@linux.intel.com> References: <20230111123736.20025-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754732911765840610?= X-GMAIL-MSGID: =?utf-8?q?1754732911765840610?= 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 1d0b743daebb..4b77c96da07f 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