Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2825751rwb; Sun, 15 Jan 2023 23:18:44 -0800 (PST) X-Google-Smtp-Source: AMrXdXuLA8A6si4Wjl8JbzwEcJhz+6ee3/wMdAxqcswtW38DHLOOe4C/gGb/8tae0H+B4TruUtgJ X-Received: by 2002:a17:90a:460a:b0:223:ed96:e3ca with SMTP id w10-20020a17090a460a00b00223ed96e3camr92106562pjg.28.1673853524781; Sun, 15 Jan 2023 23:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673853524; cv=none; d=google.com; s=arc-20160816; b=sFWZCkDBBLoYzOFZOiSOoYhFWrlcixg1rB2ww+IWJKO/2CchBKXxAy73kYRNxbID9Q Jrn8P6FUHov+izrXwrpA9A66dDRVawXnFF7pziw4vCeHnWA1LH5G7zjNq3vI/bPkGI3V 2WCPQbtQsRF6Imff5fCF2YU+o9Pow7jyfAvJcYaHme4XDhGgYJlR29QbEOzP0svp897X u9ghM5jRkhHmvTgX0PD5nottjrlVDywhREjnXihrwPAk9Fn+cdVnXXPyNcH9Q+qw88Ih oF11XxL8adDiEp/vyGoP00b+yCcJyiqSejmHD2LEzhYh9sBJLK0B05mG2vDJBN/8GuV4 TTIw== 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=Ti7IOsp+14EAKEoZumhKsxERvmaDirvODV0SODMGdag=; b=lc07JrGLh+Xzl4t2W4RAVqLjeCXjZ1P7eilchdFcTSPhfsIG6Tqv17fnQWNJcIxaB0 4aqLv8nzqMvLwWfzjErCEvsAPyTXJZkyqi4PafGbtdK/75lfQ4LqEsqSvZEtuDviNFPq FFcJoSU6238RfA8Y7OfT7TBTDaZg9IgphiIec8MAbffnww6n5s3gDEChdOJa5D8x4ARK gKW2HVMIAQlkDJvj1qq7axfufvsG1pkh53E4nuTM35Co61WUymjKOAT/dggaatg4eknO T7qfgyxKyIj5MtyHX/2x3XIigP8hjY7ESmkc0FvaJ5fsruYiF2/+6b9IyfsAKoOh9VQ5 d3BA== 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 ce13-20020a17090aff0d00b0022726215f21si18242013pjb.179.2023.01.15.23.18.38; Sun, 15 Jan 2023 23:18:44 -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; 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 S231835AbjAPHNH (ORCPT + 53 others); Mon, 16 Jan 2023 02:13:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231784AbjAPHM5 (ORCPT ); Mon, 16 Jan 2023 02:12:57 -0500 Received: from out30-7.freemail.mail.aliyun.com (out30-7.freemail.mail.aliyun.com [115.124.30.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E4EC642 for ; Sun, 15 Jan 2023 23:12:55 -0800 (PST) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R441e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045176;MF=shawnwang@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0VZdrEag_1673853166; Received: from localhost(mailfrom:shawnwang@linux.alibaba.com fp:SMTPD_---0VZdrEag_1673853166) by smtp.aliyun-inc.com; Mon, 16 Jan 2023 15:12:51 +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, james.morse@arm.com, x86@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: [PATCH] x86/resctrl: Only show tasks' pids in current pid namespace Date: Mon, 16 Jan 2023 15:12:46 +0800 Message-Id: <20230116071246.97717-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_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, 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. If current pid namespace is not the init namespace, pids in "tasks" will be confusing and incorrect. To be more robust, let the "tasks" file only show pids in the current pid namespace. Signed-off-by: Shawn Wang --- 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 5993da21d822..9e97ae24c159 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -718,11 +718,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.27.0