From patchwork Fri Nov 11 21:58:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 19011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp985352wru; Fri, 11 Nov 2022 13:59:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf4xeZo6fHY6Qn6Pq9R4qYttawZIcfqz0/dpj9yCwPT3Fp0Rzt6+2WL/Repkbjf0tnQ7xyTd X-Received: by 2002:a05:6402:1cc4:b0:462:df63:5ec5 with SMTP id ds4-20020a0564021cc400b00462df635ec5mr3228054edb.147.1668203980680; Fri, 11 Nov 2022 13:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668203980; cv=none; d=google.com; s=arc-20160816; b=mKkwnO65kUdC4hOQO4yyMN4PHl4iKoZb9esv/EjuJK3SIOlbVZEKLc7xgOwfnO/OBW IykATxhEnhYKWj05wwDfXABYGR9PUoZ5NvVALdA+SceA3BPZKUSdF2G3nZhPzfDYWlS0 DqupTbTugli+eTopKtESbunlr2jdkJ1DgVZ+iIlS+1eKLZo2wBQQA9t5clkFLwe6kKIE eB1eYraaBgpf6rDNYVLT8ubF9m3KY/m5/r8fOVl6LiwKGZSuW0sECzJJcO4kcEn+pmrP HjZQSOuFtS2f3jW+YkGS7uKGDRVVvXxOWxk8y1UfjtnGOxRT1oOqcjgoDWfeNMs1doHd 5vEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=wJ4VmNv5odo4IUQ0hbkPconHUXSlDNr+RScHZTFV53U=; b=Qiz/uWkuaQ8PoZDfwjRQxUps5OCyD+NvTLnHkuQLTrN31noSReRrOUakRLuoxje08P /IqlDVACnRkYOkMBom3a9MV9/xDkioOVolrGf6LPEIlza14mN535uJWoLumCZpFp6TOn ghx4Dx5CLsMLQUfO+n2V7TNGjYAPV9OKfRLggc0Y+RLhseXGfablhCMVY0lDkLgBKNTN 8WbDyPgpxzCPYlD2YxkNqft+0tBZR6TzY1MujEHJUb8B75vk8jbUDdX4DqxarC/uPRrx TqN8SDk8AnrSx3Yez0JHys3HH9voaL7vfPOM49A5gCQB4B1i2g21OZkEjOsFgm4VyOkg +ZZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=M0wGgN6u; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k26-20020aa7d2da000000b00461c43d1113si2765730edr.569.2022.11.11.13.59.16; Fri, 11 Nov 2022 13:59:40 -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=@linutronix.de header.s=2020 header.b=M0wGgN6u; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234237AbiKKV6y (ORCPT + 99 others); Fri, 11 Nov 2022 16:58:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233899AbiKKV6a (ORCPT ); Fri, 11 Nov 2022 16:58:30 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE91CC761; Fri, 11 Nov 2022 13:58:28 -0800 (PST) Date: Fri, 11 Nov 2022 21:58:26 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668203907; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wJ4VmNv5odo4IUQ0hbkPconHUXSlDNr+RScHZTFV53U=; b=M0wGgN6uuieIbR6A43/NR4RxcfSpKDM05g3ABWPXkhr92g94OgzyqJ2GD6Eyl6I7AZYvD8 g8vlfpx6XdC71x3ofuiIHcIZHadfIVuDeMLYWUDzP6F9Ckph/IzcfT8Z443iLA3jXUImwy H4TUkXNY4zTs6x98PjkE5UKNgMunNxGOvDWo+bwmqU4Q4NTdjCPtYIwFtzJOPF9ROWyhzA dKw8+ZnxRQ8SJgSkhpsxmz3tB8mfPpOFqq2HAPmzbGiH1LpLRdt9hogLHJibSQ2dwWfbdj fAknxGcpb3ak5lrrtgfIHHlB9ilO0kUNOPiqxCnTS0WKYmd3uIvloplf81OLrQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668203907; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wJ4VmNv5odo4IUQ0hbkPconHUXSlDNr+RScHZTFV53U=; b=84xiXbS3b+ylPabFFChdU59JYtKKb41L/BQuuddpKE5sIQv26G+e5PXbNLW2S/rdaX20U4 p9J4YHymC2+7XTAw== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] mm: Expose untagging mask in /proc/$PID/status Cc: "Kirill A. Shutemov" , Dave Hansen , Catalin Marinas , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166820390635.4906.10104879631223162906.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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?1749238657199227822?= X-GMAIL-MSGID: =?utf-8?q?1749238657199227822?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: 57d3d258198cd13ba8ef7e3f97a6d6825d2f8868 Gitweb: https://git.kernel.org/tip/57d3d258198cd13ba8ef7e3f97a6d6825d2f8868 Author: Kirill A. Shutemov AuthorDate: Wed, 09 Nov 2022 19:51:33 +03:00 Committer: Dave Hansen CommitterDate: Fri, 11 Nov 2022 13:29:37 -08:00 mm: Expose untagging mask in /proc/$PID/status 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 Signed-off-by: Dave Hansen Acked-by: Catalin Marinas Link: https://lore.kernel.org/all/20221109165140.9137-10-kirill.shutemov%40linux.intel.com --- 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 d3f8b5d..81ac12d 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 7a8380c..799e797 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 92cf8f5..91fdbb4 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 49283b8..d2a94ea 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 b9b970f..14b9c1f 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