From patchwork Wed Nov 9 16:51:33 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: 17682 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp446608wru; Wed, 9 Nov 2022 08:55:46 -0800 (PST) X-Google-Smtp-Source: AMsMyM5/OXzOxH8qg8xUlJb0C7IpD534e8oQ5xjVxF/cm+XKAPwA2xqO5BYvtQcSoWHAXPieKMxv X-Received: by 2002:a17:906:8475:b0:7ad:c04:d3cf with SMTP id hx21-20020a170906847500b007ad0c04d3cfmr55851933ejc.463.1668012945823; Wed, 09 Nov 2022 08:55:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668012945; cv=none; d=google.com; s=arc-20160816; b=u1Dv0EyJLCxw/dyMitnlCsC4nt6UnlpYZCsxOxKjIpD/XzPQbvphwNbyTZXE4p7REo 7bNoC5gx4Dxd1uMC4ItkU4qVi5EMEUX1ue3Zk9ApM4KQ9Y1/XAed2UiDQzMFSj6ErT8G 2o4PtIMBhMwgU8T413mf/TuMI4Tin46qYk7ROh08UsxxY1tQUvNl0R3i/danfeDR4CdP aE2vb5OIHz1+cXdlcizQ6ZI2PwanSq/tnIL72xH6eZ7cupeIA0NHQucjGEM7EwtCoN0+ RA1BqR2+PIZ27EKhYTZWLOTByux/i3aTl//m41WKWV4Ll8zFu3sEsqg66nSz+IpdB18H lqWg== 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=0y1kPzN8euHz5iTm3VMzL48rX8M92qtUuei7hugn14M=; b=XIOHKaGx/7DZXAr7Iczcjc9wQe0vWrIbwSe+Q4FMtVNX4NE6t2xODIZO8UprZ5LuOA X8oMGL1uos5JxdoI6dUee6ueIRQVulmty9h/B2/Tvwohy+ePlnLMTVhfoLM0rDsN+HiE e22tI8erlRAJ8OJUrXQcQDO9ctvcuJ15dTdhs1v11PJe/u2YIWKhpmNf7iNl/6uZGe6m OQeCC10qXAcQ2xmSvl2k28wpzu0R1Xh/rRpOv+o7zCppIG1GlPG2ITfYCj6L3WMn1BAw utb9O0vLTZyA/WC4XuO1FnPMHqR7QVuSuJdwF+wmWEKjOHL3wuFnbdtvniHSWgzvG0CS 4GJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="EhHKS/TG"; 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 l18-20020a1709062a9200b0077ea290986fsi11397815eje.584.2022.11.09.08.55.22; Wed, 09 Nov 2022 08:55:45 -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="EhHKS/TG"; 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 S229872AbiKIQxG (ORCPT + 99 others); Wed, 9 Nov 2022 11:53:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230388AbiKIQwg (ORCPT ); Wed, 9 Nov 2022 11:52:36 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77C6125E8C for ; Wed, 9 Nov 2022 08:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668012740; x=1699548740; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4KmDSGMvHF7ZrGPOcEVvMUSJNn2iMbIpR8ULBIekJIg=; b=EhHKS/TGcc/denCM5GU2GqQ+iVHXFOOSIxbEw2GDzhykw1+vJY6qb33T 3VdKYyKGEM6KzU82cyJ0h1ssFdB7CotGviKhMA4hoHtwhyjq4/kd+HLDk nAyMQWhRFe2ddxKKWc+kxwa9A4nwsUf2arJpNMIvFRwnmHpBgRi2fghBX yMiWio/tMphzs6c7+xiU3hqtyF5XmaKKsLPpJTuvW8sG/PRDmBFnJkYis dVFjStvEHeSCKNFXG1Tf7zHTYEAbDU0BjD+TZ2FI+JyztIqhG45YoEjpL QgFWcgrypWhDlHWVcch5Yt0+ihp4262ZbCQSrqPmFElAa7ZtGjGA5/3Ft Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="298553727" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="298553727" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:52:17 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10526"; a="587827263" X-IronPort-AV: E=Sophos;i="5.96,151,1665471600"; d="scan'208";a="587827263" Received: from dschramm-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.219.85]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2022 08:52:10 -0800 Received: by box.shutemov.name (Postfix, from userid 1000) id B46D6109475; Wed, 9 Nov 2022 19:52:00 +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: [PATCHv12 09/16] mm: Expose untagging mask in /proc/$PID/status Date: Wed, 9 Nov 2022 19:51:33 +0300 Message-Id: <20221109165140.9137-10-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221109165140.9137-1-kirill.shutemov@linux.intel.com> References: <20221109165140.9137-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, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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?1749038342493405392?= X-GMAIL-MSGID: =?utf-8?q?1749038342493405392?= 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 92cf8f51faf5..91fdbb47b0ef 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