Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp2630360rwl; Mon, 26 Dec 2022 19:11:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXtZPe3aVbHEko1KCHM4UbN66LT1zJgkJBaIk4wFoSfHq/9j0cVE6k9HWEGaJmBjebBFFxHY X-Received: by 2002:a17:90b:3711:b0:223:3fde:83a3 with SMTP id mg17-20020a17090b371100b002233fde83a3mr23063692pjb.40.1672110662013; Mon, 26 Dec 2022 19:11:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672110661; cv=none; d=google.com; s=arc-20160816; b=iTyhl+C9Sb/+PgdZZzXYZeojxXWTCdQNdJ5d21/TCMTdUL1Oa78hcBWIdmxZsg0QVi JaLaDvHigmFTABobaJR3OtgwfGj+CAE8Yjse7dJJRM1gbY+hSWvc+LTrCLnCY0Jx55Pd /J/fR/k84SeVi2AbOHHX+1lG4KmSHbZzjft+SZ3knZEUBkwp4jprH5/lTsfQOp+LLsL2 jdxJfi1urlpTJRrXg7mwRgSoCnMQ8Nscddt6hC+SO7zj/qw+ZzN6c5Qqi/0BAQbhKzh4 GmdL8blrSQ7H+VCvFT5QC0qR+rqGhphZTAUsATu6k7Oe51YI96Xsler/qXlacMStSHKj pO8w== 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=IZoWeD42yWh9XTUsLlcRaLNhHxRpiWGm/Bt6fqyV4JE=; b=PBrHaq/nMeGG/78WQFhGvqy9vn0YVICAuUNI3yBzDHS1U4RLY+YazVpRxnrKqgcxgA H49xJ3z9zhF/pyxI0vV5XgsyJ36vqPqVo/6wtZuP/rdUx9tdiYMspXT1NCYcPDnRVAnI D8eosT+5nDi+muJ8RoAmxiowMCb18yaVPTdI8VQj3wJzxZHFwOnKrbyC9tMbDEsnEh+x 06baztqCZWoHu76HUfJBXa25LxA4acCoySP/GYGob0i2fATdvBDJmZuuQnS1cFvTcInA dMlO0NBddpWAI3RXAC21REkg10LRbJKsXLPO9mf3mgUvWZgW5VJb3Apfrim4VkiRwAdS SCJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NLusNa0t; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o5-20020a17090ac70500b00213997a5fe6si12961274pjt.113.2022.12.26.19.10.53; Mon, 26 Dec 2022 19:11:01 -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=NLusNa0t; 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 S230244AbiL0DJS (ORCPT + 66 others); Mon, 26 Dec 2022 22:09:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbiL0DIw (ORCPT ); Mon, 26 Dec 2022 22:08:52 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EB71F10E9 for ; Mon, 26 Dec 2022 19:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1672110531; x=1703646531; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=2hNvtI+I64q9AU5Zc+yHHwHftID1PyaOfc87+zaI4fg=; b=NLusNa0tTl3d92B5cSckeus1ibwrLRBvcNbmvLFUM1faxNowaGQ5j/y7 XTNR8j5Yxz709mRkS1hAMzfZGGDA1igY4NXSxI7H/nI/xvLS3beDELgFz C/ziUYQLiErLuHT1Ke1s2lWOnzAST/mv2k+tbCTkp2CDbccgmT6xg+qyS /vqIB3z4j2F7CPbekT7cTSKTHQknfX1uvVVEg74jTTlBMBduckXwIbTo4 qMv+jrC3jyw+1CwvgIVD8fVYbW6V4hqt69ONZLV7n/JXSFsdYT/qFYAQ9 TFV+w3oxIRUnc5bRzpe4UXEZ8o2NzSC/PGRymUm/kpsWikZtmB8//Vc0w Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10572"; a="300994704" X-IronPort-AV: E=Sophos;i="5.96,277,1665471600"; d="scan'208";a="300994704" 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 Content-Transfer-Encoding: 8bit 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 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 -- 2.38.2