From patchwork Tue Jan 30 10:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunsheng Luo X-Patchwork-Id: 193985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1129313dyb; Tue, 30 Jan 2024 02:50:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCo5h5Wag8RMAnlE7lN2u3G4Mnoc9aS8E/75VF36/5UwB+aIxS7V+D1acACbrZvQ359y/f X-Received: by 2002:a17:906:a1d0:b0:a35:fd93:8be3 with SMTP id bx16-20020a170906a1d000b00a35fd938be3mr2137199ejb.2.1706611847865; Tue, 30 Jan 2024 02:50:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706611847; cv=pass; d=google.com; s=arc-20160816; b=q0fRBAfEnGt4p1f+KttcgeiuxNzt6Q8gKmPctA/I38ZC1G3RK9hm2YuUp2kycaAtec +N28njkMrHZw9KhapXSTbjwXfobyDK0CaS/110PWV5EKyxndClMkX4OwYlTLde4jJGSo O1xFumlfxtEirpBpceorSf/970mSjunLIwt9YjJ/RVsc9HE0jMWEchOuZ+lbqB840Sy3 A8h7iyTyS6dC8yTLr8yXrsfyyJwc2h3ZybnGMn9PcUMjUqBB40DX/kV2gJqKiQ6+HCqE KcNCU+LRKmZo9JDrw9lA4MoMD3b5Lj16yAxPQPEGBGNR0wKgcq2EQ3ECHKOw8hL91Cy7 mK7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=DWUozJucjnfH6JVEW1MxpE4BKS/k0a8AwToM/8TtzaM=; fh=Gps2WlHT2FGWyEretgDsroJjmn2OHGl9PDc8SLKwie8=; b=DUXXgtYJDKCOXluBvRNLIaSNs34UU7FoR6sY3y4La2QJ1t+iRipJgmIoCs3xYmxeFv I/Kb0xRMGt2B+rT5QW7H693S2ewO4YAdehEZBLAtyHZmOWHF5K1sa8Q1DfEgVtxEnxwE fFclZiBVYYiNNX+CBTdgiY5waykWzudBOohpdwleTX8z/l4Mj7SaQ1AE2C2uuAqD4x72 z88FZYvCUOkDGHN0nOc/EKq+I0K3lZPPR8jZVTWmMZ40Pjh1rK9Id4OHkdfPExkzjGVi Hmlgl0yKBV8HohhM3r9PdWOcmnewnCufZjAfuAf+lhxCzr/rxKDAiRri432+DaLYqg/m PeSg== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=ustc.edu dmarc=pass fromdomain=ustc.edu); spf=pass (google.com: domain of linux-kernel+bounces-44427-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44427-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ustc.edu Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id z25-20020a1709060ad900b00a34ac15e347si4347806ejf.889.2024.01.30.02.50.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 02:50:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44427-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=ustc.edu dmarc=pass fromdomain=ustc.edu); spf=pass (google.com: domain of linux-kernel+bounces-44427-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44427-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ustc.edu Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4A7E81F21A1A for ; Tue, 30 Jan 2024 10:50:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 000B56A00D; Tue, 30 Jan 2024 10:49:08 +0000 (UTC) Received: from mail-m49198.qiye.163.com (mail-m49198.qiye.163.com [45.254.49.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F15D6775A for ; Tue, 30 Jan 2024 10:49:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.254.49.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706611747; cv=none; b=ow5ZMU2ArZEokRptpClpl+ggJV0r+3rLYsSGrOpPHKcrTDsVtUW15p/dOY8JT/JXz3efyTmP9kPxKgj7eaCTiACEWccpUZ3qt+t864zMMvD7cItdpcrSMzVfE0jSzmmHyWkX91yAhb71oJXrz2OZEr8HZWXpXzar2BMzfOk4lTo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706611747; c=relaxed/simple; bh=GZufsPghWkdzEG2h/2SSA0buT7CGeIjQOid70c84efM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SIGZRuu7KOa/FVFA4R177pqj92Y238hhbSxLOdvd+a5mrEXhHWgX36fVuXNsmRNy1hEz0LDwFxS8I5eYHltcGjxJH/ql0Z3NS+xV5TDZm+/LZ42kvSBEkmGDP7V46mLzWn6lPFRG/CUr/l0Pt1ufFTqDlT4rzWHiKedwNbEM7og= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ustc.edu; spf=pass smtp.mailfrom=ustc.edu; arc=none smtp.client-ip=45.254.49.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ustc.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ustc.edu Received: from localhost.localdomain (unknown [61.151.228.147]) by smtp.qiye.163.com (Hmail) with ESMTPA id F0ECB7E013B; Tue, 30 Jan 2024 18:48:41 +0800 (CST) From: Chunsheng Luo To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Chunsheng Luo Subject: [PATCH] mempolicy: add home_node info to mpol_to_str() Date: Tue, 30 Jan 2024 05:48:39 -0500 Message-ID: <20240130104839.10270-1-luochunsheng@ustc.edu> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFITzdXWS1ZQUlXWQ8JGhUIEh9ZQVlDHUxNVkMZQk1PGhlIQ0ofS1UTARMWGhIXJBQOD1 lXWRgSC1lBWU1KVUpOSlVJSUNVSk9MWVdZFhoPEhUdFFlBWU9LSFVKTU9JTE5VSktLVUpCS0tZBg ++ X-HM-Tid: 0a8d59fc47ae03a2kunmf0ecb7e013b X-HM-MType: 10 X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6NAw6KAw6LzMOCEpKSygSPzUU Dz0KCQpVSlVKTEtNTUpKTElJT09OVTMWGhIXVRcOFBgTDhUIEx4VHDsOCA8YVR4fDkVZV1kSC1lB WU1KVUpOSlVJSUNVSk9MWVdZCAFZQUlIT0s3Bg++ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789512225257203521 X-GMAIL-MSGID: 1789512225257203521 There is currently no userspace interface for obtaining home_node, so we have added home_node to the mpol_to_str(). This allows us to obtain the home_node from the /proc/pid/numa_map. Shown below: 7fe356e00000 bind:0-1(1) file=/root/test Signed-off-by: Chunsheng Luo --- mm/mempolicy.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/mm/mempolicy.c b/mm/mempolicy.c index 9282be2ae18e..7a8800036f88 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -3033,6 +3033,7 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) nodemask_t nodes = NODE_MASK_NONE; unsigned short mode = MPOL_DEFAULT; unsigned short flags = 0; + int home_node = NUMA_NO_NODE; if (pol && pol != &default_policy && !(pol->flags & MPOL_F_MORON)) { mode = pol->mode; @@ -3043,9 +3044,10 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) case MPOL_DEFAULT: case MPOL_LOCAL: break; - case MPOL_PREFERRED: case MPOL_PREFERRED_MANY: case MPOL_BIND: + home_node = pol->home_node; + case MPOL_PREFERRED: case MPOL_INTERLEAVE: nodes = pol->nodes; break; @@ -3069,7 +3071,11 @@ void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol) p += snprintf(p, buffer + maxlen - p, "relative"); } - if (!nodes_empty(nodes)) + if (!nodes_empty(nodes)) { p += scnprintf(p, buffer + maxlen - p, ":%*pbl", nodemask_pr_args(&nodes)); + + if (home_node != NUMA_NO_NODE) + p += scnprintf(p, buffer + maxlen - p, "(%d)", home_node); + } }