From patchwork Tue Oct 25 00:17:15 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: 10442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp737922wru; Mon, 24 Oct 2022 18:10:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TepZYMctYMQ2iMQGGSMv8Oj2XaB3+FkBFpjhwFOhu+r/Qcb0OoddeuPe94N8JVbaz0qGy X-Received: by 2002:a17:907:6087:b0:78d:ee99:a06a with SMTP id ht7-20020a170907608700b0078dee99a06amr30113708ejc.52.1666660244579; Mon, 24 Oct 2022 18:10:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666660244; cv=none; d=google.com; s=arc-20160816; b=mFr4ARUqUOXUab6OgurO7gU2ace9arYwM/yTsyzBczeeU9fnAxRAt+bJynmuqEbBnY 9nERTIzFAZPLOzXM0wCh06ojacEqRhQ2e14nWXtdy2AF8HXcDB+g7YG4dQASvbv6QJhM BiRJp0yq1zV1GpXW0wnebx9oPQfk5d+LnZSq58H4BlA2eqdvVs1a3pyy2b2AAiQVJkGD AcdVGfR+Og+5ysdsRVdYDek0t0pO7dQW7wB4APCrwyEex629u/yse/sW/UpupjU1AzQC 5Q2hb87fE0NDO8St36XeGYX+y/WossX7XXpXm8E4QoERL+THJ/F5ulg27iRPz8O9L0an TjXQ== 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=09lDy9ImM4YFffVH2YsdVyHAmHhEItoKgW4WeaqFyTw=; b=YrL7CX9//DqnhFQd7tuj9MODiOMoGNW7PrLqaVPQp1Kys2YeLWB3YwAlKYSwmuCujn dN5eoQgYAe3BA0OtjTCdv16EQ9044jNXrUTfVR0uAxAVRWczE6J/8XW/NMvTpaS6RgzG K3+DIKF1ghIaBFaEp/goPxV5EHrY26t46o2WRr1YAyN9SK47sUaaQbPsYtRgGOxito4f OW5brpBpw20QGS9jyUFFI86slYBIxja2VBfVuiKHGGe8++aETzIqeCfWQU6y0Vaz320f F7efoVwZ7+I7ImGSFRe09e1ZHE0xN8BJPXIGBOTCrtWUds/uPtrkSOYODEEA1uPjbQlh rTew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GCd+NOTJ; 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 y2-20020aa7ce82000000b0044eae9b2c48si1157347edv.273.2022.10.24.18.10.20; Mon, 24 Oct 2022 18:10:44 -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=GCd+NOTJ; 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 S230035AbiJYBJb (ORCPT + 99 others); Mon, 24 Oct 2022 21:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230244AbiJYBIb (ORCPT ); Mon, 24 Oct 2022 21:08:31 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEACCDDB57 for ; Mon, 24 Oct 2022 17:17:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666657064; x=1698193064; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cE/mAE1tS/HlPb0lkn7x72bPiGqyAx36Rg2eRUbRk1w=; b=GCd+NOTJmuHOK+H4BE76tybIFTZ4VNGhk31FRZD/qRsJOSprOTqxuuNd YZ5z/I0Sf1sbI50dj6nxHdYAiJ8l1gZzn2bmn0Wm5lgNwfc7OjufOhr1u YeUfVlLBBSQPHL2MCQCYCmed/gW7v2mh8EzSMNWPiakQ/BHES5GMcTaGJ Lt+L1DEVSzocF5w/UhFLUKvSy+94rA57uOxSxTOTA4CaaKLn6PNpMpigp 2pj7sFhWtITL6btrfT1G4ZUSn7SuP7al5lFwUeIvxZwvpaFkBrKRgF2ym wkFhIxwe1v/vZofsnyUnsdixxF8qreyYk7OTwTetVa3DoHdPyspTLyl3c w==; X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="334143878" X-IronPort-AV: E=Sophos;i="5.95,210,1661842800"; d="scan'208";a="334143878" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 17:17:42 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="631447761" X-IronPort-AV: E=Sophos;i="5.95,210,1661842800"; d="scan'208";a="631447761" Received: from ghoyler-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.39.118]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2022 17:17:35 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 066701095BE; Tue, 25 Oct 2022 03:17:26 +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 , linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , "David S. Miller" , Catalin Marinas , Will Deacon Subject: [PATCHv11 09/16] mm: Expose untagging mask in /proc/$PID/status Date: Tue, 25 Oct 2022 03:17:15 +0300 Message-Id: <20221025001722.17466-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221025001722.17466-1-kirill.shutemov@linux.intel.com> References: <20221025001722.17466-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED 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?1747619932718717259?= X-GMAIL-MSGID: =?utf-8?q?1747619932718717259?= 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 Cc: "David S. Miller" Cc: Catalin Marinas Cc: Will Deacon 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 d3f8b5df0c1f..81ac12d69795 100644 --- a/arch/arm64/include/asm/mmu_context.h +++ b/arch/arm64/include/asm/mmu_context.h @@ -278,6 +278,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 5bd3d46685dc..84277547ad28 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