From patchwork Mon Jan 23 22:04:52 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: 47442 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1838639wrn; Mon, 23 Jan 2023 14:09:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXsjbzb4Y6SvN0PTE7Y95fk9vfuabHcdtK2uMBNets6dzaT19Ey+45rYso7sq3pDLRcQ/Msb X-Received: by 2002:a17:906:7f03:b0:86e:eccd:ba61 with SMTP id d3-20020a1709067f0300b0086eeccdba61mr32456761ejr.66.1674511763942; Mon, 23 Jan 2023 14:09:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674511763; cv=none; d=google.com; s=arc-20160816; b=f/Jwvuei+czPvZo6et/icl7u9ZO9OzGU2UM7B4cSgayI0aa0S49U6rg75v8y5nSMG+ TpSJAsByh9Vc/pYHldm2yWO8C0BcLO/GENhtepleW/eLZBUn8XW9UiFUFhANHDwccRyG PIR9vAfVUbJjZpb7XDNNXXjhUxqAHXQ72zbVENw3VK8Oy868pKvVzBYRTGRgnqOGaZiP w6afCGIbPuc4B939+TrpYGWjZ/rmca9PKykyVmPObCTML+u/Kbuvg58PHQ5CdC+9E5hK ze1fEpiikCe3OE36Mv3LYcQDs3CfuNL5GinZQMuAZEXvvHniky9hV5i465xucL8/jliW esrg== 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=EFiuqEF1AJ35Zpy8Sw/UigXH2q9I0vE41W1sxgJG5sg=; b=bsK8AoUyyIBDt86nEAvh+wRCk8GIY24SDbapm3r+zsKCoyw0G6t19Wf8v0iG0LW85r eGtpyMvsb8EXeFAy1ClbR5BVFO4u7Hq62fSSiOY7DA8BQkPxHj1ftU++ompR1bHQbkWl giF5WX+DNM5vL78nP60gMNcCY+Wzct4/o3SZbxbamxGLkGJE8ZYo93zmooY02fEzewgG BFwMgYBzt+l5WSjUcRDqLKqU8DgVusNf0kkUy1+XjKn7RpdhpTvMkQiEKb4kFJeOMFQX mnTXA9NPdoev290gM0yNTcrdQxJ35vnOJHvVrBxqaZCVFZNZDTt8sqJtRJZjgvTnulIK EQOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=RjPuQaSm; 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 l3-20020a170907914300b00877a940e10dsi54401ejs.248.2023.01.23.14.09.00; Mon, 23 Jan 2023 14:09:23 -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=RjPuQaSm; 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 S232823AbjAWWGd (ORCPT + 99 others); Mon, 23 Jan 2023 17:06:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbjAWWGO (ORCPT ); Mon, 23 Jan 2023 17:06:14 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BBDA38B6E for ; Mon, 23 Jan 2023 14:05:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674511546; x=1706047546; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OVB8ixW2SlvKXCjvUsAuiBNx4ctXMcDQHlcvi2JSoRw=; b=RjPuQaSmG+Vd9dZgYITMB4H1uDXuHB+5JB25CN/eoRX7AMlaNvfhguEp DAcErMugXKiq0Mo/tbNYnT5BSq1s0Elthdbdr27mRNLIb8ZkRiXg3ynPA Dvk7VRyAn3ieKYy7eKXkQQL7drRHiK7uCHSuMPlVZ9xHWTFVXFbcDhdOE FvD9jDjzxXa+F9Of3h8ds7f5uurnStspN9ZGDkfcD6ivtlPEVR2+093HS fSp3XmkiK5dd/K+yPNhUeDbBDblZR1DJmt8XUn0ZqFN+dlWTrdeo25B/G WD+ae0r70R/clqVqRVgyh3O7DkLrH1UdlOQmZxrCzz3SMLSYhVgs68+Ze Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="326198213" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="326198213" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 14:05:25 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10599"; a="694103441" X-IronPort-AV: E=Sophos;i="5.97,240,1669104000"; d="scan'208";a="694103441" Received: from ssauty-mobl1.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.46.171]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jan 2023 14:05:17 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id 79A2B10947A; Tue, 24 Jan 2023 01:05:03 +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: [PATCHv15 09/17] mm: Expose untagging mask in /proc/$PID/status Date: Tue, 24 Jan 2023 01:04:52 +0300 Message-Id: <20230123220500.21077-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230123220500.21077-1-kirill.shutemov@linux.intel.com> References: <20230123220500.21077-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?1755852847406573169?= X-GMAIL-MSGID: =?utf-8?q?1755852847406573169?= 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 | 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 ca2e2ffdd3c6..43eb6b1357dd 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