Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp7655448rwi; Mon, 24 Oct 2022 18:22:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Hehao0KRUiMN2H0z/Qjhuddfyo314YWIT3MGKvTQmRz63Q5Fnl1DoVKX58kOLE+2Y5mdd X-Received: by 2002:a17:90a:e7ca:b0:20a:966e:8480 with SMTP id kb10-20020a17090ae7ca00b0020a966e8480mr76257090pjb.100.1666660977994; Mon, 24 Oct 2022 18:22:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666660977; cv=none; d=google.com; s=arc-20160816; b=Ab/zBNkWEf0dMmobjWs4uqeTMBkv0AfOIFKtC9YHMc4PM2tLN8PFVnNfDvvx7cHySU S8x6MloRMndwCG29pFJ0WuQUb4t0IKyOpssjPwxeuQ80TcJ0g9R8Zrk3dPFaCEXEPMd3 OeOYD2ihRuJ0bu0bM0lecrMih2JobIn0WKxPUl7E4+H3K8SS+x7jGlArFc++7bqYf76Y 7Gnm4Jdeh6b8P7SWDaRY8lK+Sg08KBT3ovGvNXJH+ELosOvIIEUXw+jsBEjuRcAqffqP SJu+9LhyeFLaSdhdNrD/eKudKxZp3T+Z3GB9tbr75HyGLVj1L2otcQWuyHNqksp0OIAF +zqQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020aa790cc000000b005660f2c4b27si1269551pfk.274.2022.10.24.18.22.46; Mon, 24 Oct 2022 18:22:57 -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 Content-Transfer-Encoding: 8bit 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 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 --- 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 -- 2.38.0