Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1166787rwi; Thu, 13 Oct 2022 09:53:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4n1VvCkoijSoGspu95tea7DYU+o1J3nHmswOELnzoKdWEPS1WJfOYn8nxYhLySQm0iDeO9 X-Received: by 2002:a17:907:75ed:b0:78d:97ed:2894 with SMTP id jz13-20020a17090775ed00b0078d97ed2894mr456787ejc.739.1665680017317; Thu, 13 Oct 2022 09:53:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665680017; cv=none; d=google.com; s=arc-20160816; b=uweh7vQw2kI48Rwn94a1BThzhWWQfwz46PIAcApfUBhxMCrxQ1i7m0g6w4kJsf1eNF GCAC+zbdYOYV+imfAbirTFJ63sUxBqcxWaQMBgwGMyehXeiKxAhMEvJkJDrKQYuwCAlt wpDgjIslA8e+7Fn7pdflyv5eyLh2w6NX7G++qfYbHGIx2A/eN/Sp1Z33N9msq93yB/o6 kUA8y4UUbhchVtcR9umEWJtYZICE0Ed6nNHRsUT0g9GJTlueexfjUcRInynrNlaMpOKs HKzsk/m6khb/nEWIBClADuELnAfbk+Fdt08bX7eZ4k3Zf6VoYap5GD0jRYou1mdQTzob HDyw== 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=JbEHw5GFbGXxpSgTAnoCORfKnxkHkMtrjDyxiopNqeo=; b=AElJWhkZVNH5nkAgHubZewehvRZcg7MaKSp3cW8envpW0DHn3uQ7zoLpvW4lb/JfrR /0/tH2RN40xaAFbki7uEZI9FLM3J/IK4MTeZr8L2KsXeDaCgmcySeNOAO//N0IooTjzp oXxlt0vb1J+zQTf2i3mnR38ZiRjupVZLIbniEE2T0P6wJFI/B89YR1cu0udMf2tfO2CD lgJV30g+JsxtyuOFTg+MQtplfChtNqm5c2T1qk/ya/RGfnq9dqRPZP/kxv3gQgDtnW+h yueC6tFTZtwk1mTdy2X912pGWzujNOCOKjFKcFgWvO2/k5zVpjK6ENXSBlPz/at93F1Q 3Zyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Vs0zdDf+; 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 hq29-20020a1709073f1d00b0073866c0672asi250609ejc.73.2022.10.13.09.53.10; Thu, 13 Oct 2022 09:53:37 -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=Vs0zdDf+; 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 S229724AbiJMQLO (ORCPT + 99 others); Thu, 13 Oct 2022 12:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbiJMQLM (ORCPT ); Thu, 13 Oct 2022 12:11:12 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBC51D328 for ; Thu, 13 Oct 2022 09:11:12 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id 207so2621644ybn.1 for ; Thu, 13 Oct 2022 09:11:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JbEHw5GFbGXxpSgTAnoCORfKnxkHkMtrjDyxiopNqeo=; b=Vs0zdDf+YlXV2kY/1lvhAR7EJT5XL2g6aiyRvdSoRRqIPc6GWZ7IV2xWwd8DXODgPC Blkggy4lFWwBBC0DhLn+p9UsZge/+ZIwBr7z4dZdyOdiqqolFFJu4HhAy7hBC0ZWqgDN ECifr1+KJDstL/uO5Oldb6Wf+PBKTAb6I9ilEdEQtB3rFy0U4EyUYiQN4iXAlsMwSCmT oR1d53wS87KXFRp4Btu6kctnLwQ7NTRNqk74dnqXHX1OcZSOKdV1lxCX44MVkoC7tJAu aFRBZ+hDYE+sXiR2hdJ/NkJmWl5OfRlSvTKJu2pDXDLxK0YCgiQ6q/Yc1hDE44fhvqLg f9oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JbEHw5GFbGXxpSgTAnoCORfKnxkHkMtrjDyxiopNqeo=; b=DKlLDce4AsBsBBrpLP6l3TWhTBrkX4S8Jov9WLBi4AIreoDv39RprsPUzNZsJgXOV7 82OuM1z4cBKaEZvDrHe9DRlx5f9kW6B5kZnKwvlkTuRG6fc568lft2cYkDtUrzo0KIkQ 6FoiJ8tK9vaRJs8FV9hMEZ220Wb6jza4J2csNNVJRbNBW5ZiZ4BPDWSErj0eI47+gBWG kNCBOjFFUOiKymDzjaVL/RFQN4DwVZmb+DYQ77t6TDDou1qBlLM7PDg6cRx3d51XRhJE 0etblEEaVQpZOHhSZRgKy6ah29voo+GpI3fNqFB2FJoH1IZvohhWcpeU/WLN8SvZLLJq qr5A== X-Gm-Message-State: ACrzQf190R3J3id2q0iS0yAIiBwuSaIsyxhnmgqRjonqGn3GIB8/Hp3c lCs7pKMdZcd0dT0cLeJ9ha4RLIsH13t6GmCdDyNTvA== X-Received: by 2002:a25:e7c5:0:b0:6be:77c0:8830 with SMTP id e188-20020a25e7c5000000b006be77c08830mr679103ybh.340.1665677471018; Thu, 13 Oct 2022 09:11:11 -0700 (PDT) MIME-Version: 1.0 References: <20220913140817.GA9091@hu-pkondeti-hyd.qualcomm.com> <20221010104206.12184-1-zhouchengming@bytedance.com> <46c6e1cc-77d3-eac1-fa18-deed2bac4a0e@bytedance.com> In-Reply-To: From: Suren Baghdasaryan Date: Thu, 13 Oct 2022 09:10:59 -0700 Message-ID: Subject: Re: [PATCH] sched/psi: Fix avgs_work re-arm in psi_avgs_work() To: Johannes Weiner Cc: Chengming Zhou , quic_pkondeti@quicinc.com, peterz@infradead.org, quic_charante@quicinc.com, linux-kernel@vger.kernel.org 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, 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 Thu, Oct 13, 2022 at 8:52 AM Johannes Weiner wrote: > > On Thu, Oct 13, 2022 at 07:06:55PM +0800, Chengming Zhou wrote: > > Should I still need to copy groupc->tasks[] out for the current_cpu as you > > suggested before? > > It'd be my preference as well. This way the resched logic can be > consolidated into a single block of comment + code at the end of the > function. Sounds good to me. If we are copying times in the retry loop then let's move the `reschedule =` decision out of that loop completely. At the end of get_recent_times we can do: if (cpu == current_cpu) reschedule = tasks[NR_RUNNING] + tasks[NR_IOWAIT] + tasks[NR_MEMSTALL] > 1; else reschedule = *pchanged_states & (1 << PSI_NONIDLE); > > > @@ -242,6 +242,8 @@ static void get_recent_times(struct psi_group *group, int cpu, > > u32 *pchanged_states) > > { > > struct psi_group_cpu *groupc = per_cpu_ptr(group->pcpu, cpu); > > + int current_cpu = raw_smp_processor_id(); > > + bool reschedule; > > u64 now, state_start; > > enum psi_states s; > > unsigned int seq; > > @@ -256,6 +258,10 @@ static void get_recent_times(struct psi_group *group, int cpu, > > memcpy(times, groupc->times, sizeof(groupc->times)); > > state_mask = groupc->state_mask; > > state_start = groupc->state_start; > > + if (cpu == current_cpu) > > + reschedule = groupc->tasks[NR_RUNNING] + > > + groupc->tasks[NR_IOWAIT] + > > + groupc->tasks[NR_MEMSTALL] > 1; > > } while (read_seqcount_retry(&groupc->seq, seq)); > > This also matches psi_show() and the poll worker. They don't currently > use the flag, but it's somewhat fragile and confusing. Add a test for > current_work() == &group->avgs_work? Good point. (tasks[NR_RUNNING] + tasks[NR_IOWAIT] + tasks[NR_MEMSTALL] > 1) condition should also contain this check.