Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2273044ioo; Mon, 23 May 2022 14:31:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeYu8O1Ziwumq8qLicd8vgMbaXRpqwbnCiHBrrdnd74TAb15oAJUunrq40KjNvjI4nJt/T X-Received: by 2002:a17:90b:3b46:b0:1e0:80d:ebc8 with SMTP id ot6-20020a17090b3b4600b001e0080debc8mr984633pjb.229.1653341460429; Mon, 23 May 2022 14:31:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653341460; cv=none; d=google.com; s=arc-20160816; b=Fyo4WTB4qjZAu8za55M+nyerCl4dcUXjh/mROMdWEP5znnzZNIEKLNOf0DBPT0RT76 tTXaDSQM5kgmQEvJSPh4esyKtCII3AaY3lCclX3M8Jsv5QMkMPj8mbhdPpMc9Bd8f93J MnXln/DrK296TWBecL32uN2vEqZonKWTBhanK8j1qFfxq9jIR4gjb2Pfmlt5m2xNU9Rk R7P820AnjijfiO5EvEST30RAgzl5wMlcmVT89wO3TuSDyYwoBSJxzvCrG80eLs1EmgRM zb+sztyWVBNedIcDGEdTetqMwb5dME/EPJnT8z6bdjLDoL9bK3d2fi6pMRSI9kCf2dO/ vCzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=oLDY4cmr222gssu19D12pJ5dYihqNZnukAxsU+Y1ejU=; b=YLxOOsPd47C6jIiMZcGNMBskk968F7wzrmTX0xyPuDQs2i/oIbE8K7BTJBvfYd/ga9 sWjBURh0dBLeShcfGnCPvTNh4Lrmh1McgterHA4RRr5kCDDm8LBc+1u/YuLnxU+TRwFJ We9C4NisXYmeDbw0foUqMmRTnrp3+/wB8psGhBXY8bkIE8s2KDJODkLL25GyRZU01iU1 JhowYed/4NZyMHBIj3BvGegy4CqxeVfJdYCsIbyFL+HVVHPDWvlCFczq5dlYtSRgoodV FUdaAnuTpysQrN3qpAY0FVMAvML2iehaX4xj5PClQYovQYMwwejZQ5+XsGu9qxS/t5Wq ausQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=TpnIFJb7; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s16-20020a17090ad49000b001df54bb6d5fsi433479pju.130.2022.05.23.14.30.49; Mon, 23 May 2022 14:31:00 -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=20210112 header.b=TpnIFJb7; 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 S231560AbiEWVTu (ORCPT + 99 others); Mon, 23 May 2022 17:19:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229677AbiEWVTs (ORCPT ); Mon, 23 May 2022 17:19:48 -0400 Received: from mail-yw1-x112a.google.com (mail-yw1-x112a.google.com [IPv6:2607:f8b0:4864:20::112a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40F958E1BF for ; Mon, 23 May 2022 14:19:48 -0700 (PDT) Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-2ff155c239bso162876547b3.2 for ; Mon, 23 May 2022 14:19:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=oLDY4cmr222gssu19D12pJ5dYihqNZnukAxsU+Y1ejU=; b=TpnIFJb7O/pdBIh8GUMlw6sWMXiJFEVNwuRhxPHn/pS6eG4jN6V0v2RzhCj/pd35EC 8lq2QhNInOnvmqq/zm4SEz7YYfPZ5EQYXPjVarG0ekP3j3lvV8K8HIbeyz9ASKnTk4QS LP+4y+UfTGkKM4PdkuW0IVuwO5VawqXUTE5pnWjLtqVgS6nWJtSXnw7D5Hn8VBOA1T5S 7G/KKhAAwpio8PNKPqvbIJBJyp4ZV4MJZllDzlxdv5reJbK6keUzJ4cAY6yRl1qIXoUQ CbrS65lral4Fx6CrW683Kz+ekjveuKIrfouYulpG/Z6Fsue+KcdNmeGw6+02Lawm4lhM YS0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oLDY4cmr222gssu19D12pJ5dYihqNZnukAxsU+Y1ejU=; b=HZoBZMBP40Mvmqq9W1WvQgPThKeKp88tpb8ZdvyjaNYrois07ZtAWKkn+W6keEKBIZ 9Ve+8oHmyMdvaMCVg8gSn68j/3DHsy0y+k/PDof0anMRs8ec1ZxPTZjmM0PDAQfY5ayF wnYhWw8v+S/K+YcpNlNdmE0nGyTGzP01vmm/XeagFaqYy2v6DXCEj1nqSZL7tvVIsTQw Lb0snbduxdP+c00x2M2tWCvcyKrfEoHFREp1GoU9XiVfsAO14eyXg+AkzWtuT0piV8Ze +DhWHjAIWW9JlZfg6rIBf9J4aqiMYVLDzYMX1ImVwQ3Q17b1ggvzsr3w0ZP9PzibaIl2 BQQA== X-Gm-Message-State: AOAM533rTrPrZFL4qvFDT1bXmv5WKVg491GBzClJ51aokCXW5CNZoGwp vMxruiVBNZiku7DNgzKtvAm4W34iUjskoeQU+SQ+RQ== X-Received: by 2002:a81:2388:0:b0:2ff:a07a:517a with SMTP id j130-20020a812388000000b002ffa07a517amr16294486ywj.201.1653340787230; Mon, 23 May 2022 14:19:47 -0700 (PDT) MIME-Version: 1.0 References: <20220520235138.3140590-1-joshdon@google.com> <20220521100037.GA2578@worktop.programming.kicks-ass.net> In-Reply-To: <20220521100037.GA2578@worktop.programming.kicks-ass.net> From: Josh Don Date: Mon, 23 May 2022 14:19:36 -0700 Message-ID: Subject: Re: [PATCH v2] sched/core: add forced idle accounting for cgroups To: Peter Zijlstra Cc: Ingo Molnar , Juri Lelli , Vincent Guittot , Tejun Heo , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel , Cruz Zhao Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,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 On Sat, May 21, 2022 at 3:00 AM Peter Zijlstra wrote: > > On Fri, May 20, 2022 at 04:51:38PM -0700, Josh Don wrote: > > > diff --git a/kernel/sched/core_sched.c b/kernel/sched/core_sched.c > > index 38a2cec21014..ddef2b8ddf68 100644 > > --- a/kernel/sched/core_sched.c > > +++ b/kernel/sched/core_sched.c > > @@ -277,7 +277,11 @@ void __sched_core_account_forceidle(struct rq *rq) > > if (p == rq_i->idle) > > continue; > > > > - __schedstat_add(p->stats.core_forceidle_sum, delta); > > + /* > > + * Note: this will account forceidle to the current cpu, even > > + * if it comes from our SMT sibling. > > + */ > > + account_forceidle_time(p, delta); > > } > > AFAICT this is the only caller of that function. > > > } > > > > diff --git a/kernel/sched/cputime.c b/kernel/sched/cputime.c > > index 78a233d43757..598d1026d629 100644 > > --- a/kernel/sched/cputime.c > > +++ b/kernel/sched/cputime.c > > @@ -226,6 +226,17 @@ void account_idle_time(u64 cputime) > > cpustat[CPUTIME_IDLE] += cputime; > > } > > > > + > > +#ifdef CONFIG_SCHED_CORE > > +/* Account for forceidle time due to core scheduling. */ > > +void account_forceidle_time(struct task_struct *p, u64 delta) > > +{ > > + schedstat_add(p->stats.core_forceidle_sum, delta); > > But then you loose the __, why? Yea, this is probably better off as __ and a comment on the function stating that it requires schedstat is enabled. My original thinking was that it would be nice to avoid capturing this requirement here for future potential use cases, especially given that the schedstat_enabled() check is basically free anyway. > > + > > + task_group_account_field(p, CPUTIME_FORCEIDLE, delta); > > +} > > +#endif