From patchwork Sun Mar 12 11:26:04 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: 68275 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp674975wrd; Sun, 12 Mar 2023 04:29:56 -0700 (PDT) X-Google-Smtp-Source: AK7set+UkGSAzW2FRhjJBFo6URryLOD0aoGHfMrHEgML9ok88P1ple16/FyooLoF5qGpM17w2CvZ X-Received: by 2002:a05:6a20:698b:b0:cd:ed5c:4b8 with SMTP id t11-20020a056a20698b00b000cded5c04b8mr28300906pzk.18.1678620596158; Sun, 12 Mar 2023 04:29:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678620596; cv=none; d=google.com; s=arc-20160816; b=zRtyDzZZSi08VfgVCEtg3OPOA2dzWPqySYIC6cDZLef77QqbCOq5Q46TfbH5BPU3zP he+c+2nmwdf7hcU6P4dXhCFozVCWfM2PddTyUkcOT3OQO0F6sVrrEiT18be0HQ90Suyi zlUDDddbhJvDtaPZCRiLS5P/rzUPSDLnQclrnh1B6bxnnZWaVkkAV7mhwKGov54EatGF wPt7pr/OxWmftfARKEjEFIoNuYznzebkbHdVyo5K5mifABEfsNPDkOUvgFDA7E03e8Hm BD2dqF2PJ+MTpwN2HwL0LTHTfblnknOvpPJ0iYzq+OEixgq85dBjTAMwG41qDRKAHEU1 OZsw== 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=+t7c0GIEcRYZsAa/7kH4wF7e/+Xbyk3x8s2toycvq8M=; b=e9ey3RGsRZd1QTnWH2rqtSavbH6K5o7/Faq4RlQutvHHg4Uv/AOsfmqjyhkwbguyWh g7gngNtOym+xgjIkj4KTmLSX1RNzWVMrBAQSy9YqS6TAcfQDriOlbNswfbdHy63Zg+09 db1CYmcxXDxviBr3yjWkgWYImMpwaDv56ttq6Xh5fU8aIuEb1RMI+H5O7LPEi7MW4kYQ HLxEAi9jAldtTX2RX26oeGtkrm6j09q1h/hycxTcRZevAZ6VTs0+F56AUhoo89mS3//n 5bUNXact5YWPAWPg58jeEhml7t35BDIm0tga3AXcR4ZI6e+RzFlJjqNEeN+o+ffuFAiJ uUcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eww8sX4S; 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 a6-20020a631a46000000b004cf7904ba60si3943312pgm.25.2023.03.12.04.29.43; Sun, 12 Mar 2023 04:29:56 -0700 (PDT) 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=eww8sX4S; 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 S230305AbjCLL1x (ORCPT + 99 others); Sun, 12 Mar 2023 07:27:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230416AbjCLL1g (ORCPT ); Sun, 12 Mar 2023 07:27:36 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99FFB52F78 for ; Sun, 12 Mar 2023 04:27:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678620435; x=1710156435; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=dORBfkbxhzi1hEEMwZ37gZ5mNHOdLznvEXqItjRFy7I=; b=eww8sX4S44/68TdF8QPGmaDF3L4OCHtSSV8foOx0eVm8KatkwFcXRkRw MO0s5BTHvo/R8SInWBqkUvJWGzQjmT1XHEbn5Vtbq2gauld1B288bTu9+ mdy9xKhc4K1IHdWiZx00hg+w00a/9mKA+O+0pD3nGh5XkR2XjaIvUnePf v6oM9fGykTKM0MOeKvnWLNdiHfWX+IqX1DYK6iJxfwKmNq51xSFEaGoAN exlw/nZP1Z/bAK2Z2pDNnWEZ35BZU8+voT4hQrjfTaVNCicGyo9w03LTo gDaLHoh7tKdITz7oo7HIBwre6L/nTYxb+CK9zvH7/8TRjVukGKL/fxWqU w==; X-IronPort-AV: E=McAfee;i="6500,9779,10646"; a="399577585" X-IronPort-AV: E=Sophos;i="5.98,254,1673942400"; d="scan'208";a="399577585" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2023 04:26:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10646"; a="671580737" X-IronPort-AV: E=Sophos;i="5.98,254,1673942400"; d="scan'208";a="671580737" Received: from nmoazzen-mobl1.amr.corp.intel.com (HELO box.shutemov.name) ([10.251.219.215]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Mar 2023 04:26:30 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id AF00310D7B7; Sun, 12 Mar 2023 14:26:19 +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: [PATCHv16 09/17] mm: Expose untagging mask in /proc/$PID/status Date: Sun, 12 Mar 2023 14:26:04 +0300 Message-Id: <20230312112612.31869-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230312112612.31869-1-kirill.shutemov@linux.intel.com> References: <20230312112612.31869-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?1760161269872975110?= X-GMAIL-MSGID: =?utf-8?q?1760161269872975110?= 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 | 7 +++++++ include/linux/mmu_context.h | 7 +++++++ 5 files changed, 32 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 eb1387ac40fa..06eaaf75d572 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -104,6 +104,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 9b0315d34c58..6daea628bc76 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -91,6 +91,7 @@ #include #include #include +#include #include #include "internal.h" @@ -423,6 +424,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) { @@ -438,6 +444,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