From patchwork Wed Mar 22 17:03:06 2023 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: 73536 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp2455082wrt; Wed, 22 Mar 2023 10:06:22 -0700 (PDT) X-Google-Smtp-Source: AK7set+jRINts5sgrGbrF1UZD+xfiSuGsS0rRPRBw0DOPMsGchNDvRfuRfkwT1oUdvxgbiSbRCvz X-Received: by 2002:aa7:c451:0:b0:500:58c2:41f3 with SMTP id n17-20020aa7c451000000b0050058c241f3mr3056155edr.19.1679504781979; Wed, 22 Mar 2023 10:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679504781; cv=none; d=google.com; s=arc-20160816; b=fZdNf1syh46zbYkxrwHmYgbyIjSPuUgn6nS23OGguP+nMCqCbMN0xTqUNOAd/DxNNj pJFdQMnOBnfzfT7PQ/PC/Jq/ciG71eillM+Ys6Cdgb1QX+BTS9MN+GqHbkktjYx/JCwK 8vxS0MG+qZ4ksMIK/C2wrxRmLCHFtSBPZYRtNRdmt4Bf8nd4OUO8hTXm+bQ6g97fzxww jvtae7brb36A+bTRHkSFnrdajjBFtWahYiRY6gZWf2fN4KO28w4l/an1Hn+ZbxMZ9mpo 90dh432lDVo/7PpjOsqFTgWwD7GbaPqEjcMhkch0JUcMBEXWYhPNHMEogmvcDZYmX1ax bbjA== 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=etTSmXrHU8UUxgpLu3aX2UgX8Rd8wKMSZtrj1BlNtjk=; b=ZQxwy2NnfUHd7sz/yR9laRtrHk82PKwG0awuY9y26xxU+/6lo8FsOFmKPz/J7dmt2/ wolGH1UEKwOy2G4PDclIOMXU8aDeioBh6kqMi5anlDA/u6LYWg3LMGlGUhFugLePuh2N AFjxRdcrdvmnYi6l6iA5HRuCYll6WdckaWn9N3CsmADO5z5S+noQXRFKjHEa/xtXMDCv ZOk/rIQYXSgRvjVdgO9LDjPZ6izYwalgDMQnQWfNCwCRJM8urqI6XFC/GKGYhMHRjRVc Os6i3v678zEgAo0/cjPbZ/fJwpIvZ3HB5dvMSgYl2T8d/1gc3GLglsSQgDyS+o6nGBFR NO3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="AnBE/dxd"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ODmQMVd9; 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 gt18-20020a170906f21200b00926b9cdf363si15674588ejb.552.2023.03.22.10.05.57; Wed, 22 Mar 2023 10:06:21 -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=@linutronix.de header.s=2020 header.b="AnBE/dxd"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=ODmQMVd9; 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 S231312AbjCVRFG (ORCPT + 99 others); Wed, 22 Mar 2023 13:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231441AbjCVREd (ORCPT ); Wed, 22 Mar 2023 13:04:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0E2A4608F; Wed, 22 Mar 2023 10:03:51 -0700 (PDT) Date: Wed, 22 Mar 2023 17:03:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1679504587; 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=etTSmXrHU8UUxgpLu3aX2UgX8Rd8wKMSZtrj1BlNtjk=; b=AnBE/dxdjfvn5Ipt7/lLx1wNxiI8aQ3I2hJMx1gMpPpsOC8CnbcF/TRZnn1hpjmXSexZhh g6unvEUyiP/DTaE3yltQfFzBN5EcYhMyHxprG903swPfJQAWiAs+j1pcRwANzF1qA6Cic0 IFRE4ll/5Dz52z2H9UPPEXWFerdNKzQ2Oola/XU8ceLVQa5Pq/sKRGmiyv7T+VEKP3rHwF EKYaYuojLAg1DeuY+VmOc69JaCxZ1tNqFNwKOqJEBKpj/JYg8ll866XdAJrTlIBR6Z8MZ+ 3ddHxJtNb+er8yGtlwyChpJDqas/TXGNXMkhzTAcIdGa8OvMbcd7XSv6i3gC7w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1679504587; 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=etTSmXrHU8UUxgpLu3aX2UgX8Rd8wKMSZtrj1BlNtjk=; b=ODmQMVd9Jfb4x1+0pIddx4r0EvinxRajnTH77wdeDtoOaZb6RhC7mMFf/RvI7YIRbBag5P dkjMggJ62IwbCyAQ== 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 , "Peter Zijlstra (Intel)" , Alexander Potapenko , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <167950458685.5837.10434749489202545544.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable 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?1761088406546999876?= X-GMAIL-MSGID: =?utf-8?q?1761088406546999876?= The following commit has been merged into the x86/mm branch of tip: Commit-ID: f7d304343b9d2456ffba23b99d2345408251ea45 Gitweb: https://git.kernel.org/tip/f7d304343b9d2456ffba23b99d2345408251ea45 Author: Kirill A. Shutemov AuthorDate: Sun, 12 Mar 2023 14:26:04 +03:00 Committer: Dave Hansen CommitterDate: Thu, 16 Mar 2023 13:08:40 -07: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 Acked-by: Peter Zijlstra (Intel) Tested-by: Alexander Potapenko Link: https://lore.kernel.org/all/20230312112612.31869-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 | 7 +++++++ include/linux/mmu_context.h | 7 +++++++ 5 files changed, 32 insertions(+) diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h index 72dbd64..5691169 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 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 eb1387a..06eaaf7 100644 --- a/arch/x86/include/asm/mmu_context.h +++ b/arch/x86/include/asm/mmu_context.h @@ -104,6 +104,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 9b0315d..6daea62 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -91,6 +91,7 @@ #include #include #include +#include #include #include "internal.h" @@ -423,6 +424,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) { @@ -438,6 +444,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