From patchwork Fri Apr 21 14:17:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Newman X-Patchwork-Id: 86343 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1104037vqo; Fri, 21 Apr 2023 07:19:31 -0700 (PDT) X-Google-Smtp-Source: AKy350aTNTg7Zkl7Mlfrg8IPlXxv2oF1NJX2kzSetxLstlrvv4E8Ov8RDOw460MxYVrGW1gfh+al X-Received: by 2002:a17:902:c408:b0:1a8:ac3:47b4 with SMTP id k8-20020a170902c40800b001a80ac347b4mr7223077plk.20.1682086771672; Fri, 21 Apr 2023 07:19:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682086771; cv=none; d=google.com; s=arc-20160816; b=u/y1NGJMnPu/q9KpCuploT7ObdASxamjP0BKE0/4ZUiu/EsKfm2sjMBatURJltldWS IHwiyVegwiyNAgWGBsOEUT17daqXaia450qAw3GJOdTOUZnCvbkuXcLXw5mmEsVZuj6j 82gxYqWHuadjS4PnNLCqH56BDWU6rvKosnMjKu88C7mNI+hrbIyPfaFhckPz2yiQozls vgFEGi6p2PV7395qfNp98Q+J/cDeMMElsU2NECAoStMG6peTshXsjqxZ7wfw+VX+y3PY +gV4o2ekIBsgMyM+1v50hpNePk6AdH1aoX6pQ3Y7LASXtnI3uH3KABCjYlU2BhkOdQ1L ZzbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=pHZMVL6RAnw5G7UfUNTFa5CzwFEHRn1u+l8+oLzhKx4=; b=QOcDv6oLc8GEQ9BQ8aD58loPB2vHapJLcq23WIRobgu1BA8K+C3OJoOP5EuTXvsgDA MkkUn0IDu0i0LTNr/WwbZvQS53vR/7c6hmVtSvCHkWXyfLjXSF4JIWQtjrYgxZUrEUlf RMi2z8vE1h/oWEDUj7H85SAzFJrLlTPMBOUJ4a9ctxfYSrliLVb15+iJmz4+J8RAMDMJ 5fxQM8sokRMeZek3ri+9jtlPlTAlmRkoTml9ulFBhVwtSaPQPzgNMlpvNaBYlIWOgO4l GkK/69PhbZgZxUXpWyYMD7J/AF9zk0Rcnfa0i2jjuw+YJWTvG/SkFZIvCGyfmbidEQFJ K+NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=MfKd7cn5; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m12-20020a170902d18c00b0019aa3505620si4037825plb.284.2023.04.21.07.19.17; Fri, 21 Apr 2023 07:19:31 -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=@google.com header.s=20221208 header.b=MfKd7cn5; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbjDUOSX (ORCPT + 99 others); Fri, 21 Apr 2023 10:18:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232248AbjDUOSB (ORCPT ); Fri, 21 Apr 2023 10:18:01 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C523012C9C for ; Fri, 21 Apr 2023 07:17:59 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-b98ef5b557fso1821614276.2 for ; Fri, 21 Apr 2023 07:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1682086679; x=1684678679; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=pHZMVL6RAnw5G7UfUNTFa5CzwFEHRn1u+l8+oLzhKx4=; b=MfKd7cn5Uub1nNM2RiV3ISktGqpLP5EyFHMUPTILCfI1qopVg8PNxzIa5VZ+WVXZcx YZQQ69rym1OqIQnu263AjZ26mfrN9dRc/O+yt9qJlZr0OQWY7+sFU45p712eZ73X/pq+ 4Nuhsixxps7DcDhS8ICV53xkgX4iMhzzYLMYV6mG4O4qavIN7UXl1yLnU6UYwzdbAfEJ XNoVRfO8lEMNDiQ7idtMdbVoXBEUHQvqduc/A77nuADM4Lw/KkA2p6bc2WIgZsi3U3N/ trNTBvt2RGd59HStffaZOaFrM5q5/qYO3yTC7XGOJfGCsPSLoeWY96CWcfKm4Xj9mPLG QXQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682086679; x=1684678679; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pHZMVL6RAnw5G7UfUNTFa5CzwFEHRn1u+l8+oLzhKx4=; b=WG7eALEQKF6SLx/ZrIdyfuA+tAipUWPXX/1tQhEjdNttEulfZBQDDMvQLnhTeRsmns UvLfI9Om67+Z01AdoxnhHxdGl64u21ZPL32AqDW1rePDh97OR4sLWxav12Mlipq82xNu jcxv+rRwEcddbJUUA2GRqhmWYE/fbycJbOQfT+FvtC946OdvC2wxkYmqMXKZhhZZQ9/h 8TZZutdVU3Qogzo+Bph4qDi7V8HAQTnvZWzHAyn5PBDq4ndMjTLNWPJTP+Ou9FFiGOFK O7IcwYAFz3PwZC6UFIrOGjvVOgzNS8Fpvfmh+sdzQWtwXsAb3cI3vupbzd6/UWRnDS+T zmGA== X-Gm-Message-State: AAQBX9c1twgwXiy/Px/UdHL0JdNC1nSt+vS+/nS8jlSBGGLKV+5RZUrE dKEhJe5myFnazbWfrJcKuYb2fz1RUlL7EtHxsw== X-Received: from peternewman0.zrh.corp.google.com ([2a00:79e0:9d:6:c801:daa2:428c:d3fc]) (user=peternewman job=sendgmr) by 2002:a81:ae68:0:b0:533:8f19:4576 with SMTP id g40-20020a81ae68000000b005338f194576mr1440134ywk.0.1682086679114; Fri, 21 Apr 2023 07:17:59 -0700 (PDT) Date: Fri, 21 Apr 2023 16:17:19 +0200 In-Reply-To: <20230421141723.2405942-1-peternewman@google.com> Mime-Version: 1.0 References: <20230421141723.2405942-1-peternewman@google.com> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog Message-ID: <20230421141723.2405942-6-peternewman@google.com> Subject: [PATCH v1 5/9] x86/resctrl: Call mon_event_count() directly for soft RMIDs From: Peter Newman To: Fenghua Yu , Reinette Chatre Cc: Babu Moger , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Stephane Eranian , James Morse , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Peter Newman X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763795818275612897?= X-GMAIL-MSGID: =?utf-8?q?1763795818275612897?= There is no point in using IPIs to call mon_event_count() when it is only reading software counters from memory. When RMIDs are soft, mon_event_read() just calls mon_event_count() directly. Signed-off-by: Peter Newman --- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 9 ++++++++- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c index b44c487727d4..b2ed25a08f6f 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -534,7 +534,14 @@ void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, rr->val = 0; rr->first = first; - smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1); + if (rdt_mon_soft_rmid) + /* + * Soft RMID counters reside in memory, so they can be read from + * anywhere. + */ + mon_event_count(rr); + else + smp_call_function_any(&d->cpu_mask, mon_event_count, rr, 1); } int rdtgroup_mondata_show(struct seq_file *m, void *arg) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 256eee05d447..e6ff31a4dbc4 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -115,6 +115,7 @@ struct rmid_read { extern bool rdt_alloc_capable; extern bool rdt_mon_capable; +extern bool rdt_mon_soft_rmid; extern unsigned int rdt_mon_features; extern struct list_head resctrl_schema_all; diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 3671100d3cc7..bb857eefa3b0 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -57,6 +57,11 @@ static struct rmid_entry *rmid_ptrs; */ bool rdt_mon_capable; +/* + * Global boolean to indicate when RMIDs are implemented in software. + */ +bool rdt_mon_soft_rmid; + /* * Global to indicate which monitoring events are enabled. */