Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1583798rwd; Sun, 14 May 2023 23:21:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6k184VyIR91OuFUKQaHN3w+JuJdUcc0vpBOpE8j33YlErBiDh5bVUZ0qAwODHqc+iU8tJg X-Received: by 2002:a05:6a00:1d14:b0:643:90ee:56f with SMTP id a20-20020a056a001d1400b0064390ee056fmr42531716pfx.1.1684131674527; Sun, 14 May 2023 23:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684131674; cv=none; d=google.com; s=arc-20160816; b=vDKixBjVTsec9oKRm4nRiRnY1zf7Ha1XZYor52OhrcjG0mEcjX6ZXPckpNF/cMEvsi +7zNBRDQCIEDQIPmCMijP3n4fWmvX8/+WlSaxeR/wY4ZxuFzaMb+pFp9nmDUa84lUpTu AVCcLeafbmT7kZBSlwk2vlIrl9Vtkn1+pcDZIVZdEg/KwP/flUjpweLZjIb7djCeF8IN j3rlVVK1z5USarv+LhDfP373kP7okw3XpAVHAj1zivjtT1MEbw1xTOMDN9gKM5ReC8x0 BTYWos320EdrVD389jgjIVc9H/cI5Jw++90rI9Nb/SSEv1O8Conrgqbtg8AtQRVkVT1+ Z6nw== 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 :message-id:date:subject:cc:to:from; bh=YDwXgP4aNVpWGdF7PEBCWW3b/GbMw8lshBPk4jXRrRU=; b=wOopelxpspkXN7vHd++OJ1jKATJ4VBXFUP3PdLZcfAKC6fT98B9+dqXpYhUNohVQ+F noKPuEMRuSuSjAA6epMQHZWtqOA+Wmb/9KRHXaIRt8JQVvLqI+CVyMD8ttmP/oe0I8uV UnLqojBsJUQMMMgJ2Vbu9vditAiIjze/+F6nt8x0dWGKW9+pH3ZV+SFCvqBj7+M7XG5L T94SZ/4DLRdJ0HlWK4CNC5iW2sHy/2PBasE8lqXfbJvVw864fx3JA1djufI0FQPVI7UH VXNteqDJO+sYlKBBCl3uAYv7D5PO/o4P7uCn3tmbiqo1I1bQjF/bCgI2/jMIn/6wXcfE 6csA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020aa79909000000b0064397f082e6si16073394pff.349.2023.05.14.23.21.00; Sun, 14 May 2023 23:21:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229869AbjEOGH6 (ORCPT + 99 others); Mon, 15 May 2023 02:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239284AbjEOGHg (ORCPT ); Mon, 15 May 2023 02:07:36 -0400 Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74EB630EF for ; Sun, 14 May 2023 23:04:56 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R101e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=shawnwang@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0ViakDq3_1684130688; Received: from localhost(mailfrom:shawnwang@linux.alibaba.com fp:SMTPD_---0ViakDq3_1684130688) by smtp.aliyun-inc.com; Mon, 15 May 2023 14:04:52 +0800 From: Shawn Wang To: fenghua.yu@intel.com, reinette.chatre@intel.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: [PATCH v2] x86/resctrl: Only show tasks' pid in current pid namespace Date: Mon, 15 May 2023 14:04:48 +0800 Message-Id: <20230515060448.50446-1-shawnwang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.6.gb485710b MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY, USER_IN_DEF_SPF_WL 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 When writing a task id to the "tasks" file in an rdtgroup, rdtgroup_tasks_write() treats the pid as a number in the current pid namespace. But when reading the "tasks" file, rdtgroup_tasks_show() shows the list of global pids from the init namespace, which is confusing and incorrect. To be more robust, let the "tasks" file only show pids in the current pid namespace. Link: https://lore.kernel.org/all/20230116071246.97717-1-shawnwang@linux.alibaba.com/ Fixes: e02737d5b826 ("x86/intel_rdt: Add tasks files") Signed-off-by: Shawn Wang Tested-by: Reinette Chatre Acked-by: Reinette Chatre --- Changes since v1: - Update commit message and commit tags. arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 6ad33f355861..61cdd9b1bb6d 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -726,11 +726,15 @@ static ssize_t rdtgroup_tasks_write(struct kernfs_open_file *of, static void show_rdt_tasks(struct rdtgroup *r, struct seq_file *s) { struct task_struct *p, *t; + pid_t pid; rcu_read_lock(); for_each_process_thread(p, t) { - if (is_closid_match(t, r) || is_rmid_match(t, r)) - seq_printf(s, "%d\n", t->pid); + if (is_closid_match(t, r) || is_rmid_match(t, r)) { + pid = task_pid_vnr(t); + if (pid) + seq_printf(s, "%d\n", pid); + } } rcu_read_unlock(); } -- 2.31.1