Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1738470rwi; Thu, 13 Oct 2022 19:12:46 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7lbF+Ob2dOwJfkJmm7a0dg2I5bg1nLx37JRE5pQH7HCFJUvYhXi8+HN518KMVDdqx07IRH X-Received: by 2002:a17:907:75e5:b0:78d:cb12:6dcc with SMTP id jz5-20020a17090775e500b0078dcb126dccmr1831547ejc.550.1665713565778; Thu, 13 Oct 2022 19:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665713565; cv=none; d=google.com; s=arc-20160816; b=fVlD2d2Oixk+pDvjmz57GV84d9m+++GTAlyl1vf/UJAZmbNnJ31ZAxtZZKxUHjmc/G OUxddJxAJOHqdkkVX4hzo3p1ro2zCt5jHyHAoNoeClkqDoOJDuHYTEX2bQughbnQdwwn oEsFPXhwS/0Pk69FtlneYAP6e2W7zu/VxuajzNcm8pTYfW5JRanXI7vPCmAZGrheVuUE Qd5KsTaiGddk3USLBPanTpJXBEIPU2M3TsAzlcH2rzAwNV/QYnyS2meFoRgKEfOZ37v6 470+fv6nV4wrudBEUrol3XjpLZ16UFZ1OFg3b1eIYzfoyOEz49vs98zYKDaTxDCPi1NC gsKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bFZZy9pvaOE5FXP35cf1kMoA7/k/1JqmLQ8oHebi89Q=; b=kw+h6aD5Wky5Ar1306wZ8FP6HzxbokQwP5WyY0T3h4c6prNz5y4EQESVjf8T2tN0lq hqxpR4q/YPjFRliO6AgMf9atB48MG4ukgrwOqxaRmbc796+PhCbhKglKAz8azi8ouO1M u2YR/Cr5kLLQ9WE4X9kwcnu7ihXmaBe+2aCY7kLlG0Bmu/7PA/u0FhPp2VxBDWK6Y5Rv 8a2og4WfmKOrd1LXaTuqCqPRz1fqVNYsuTJ4i0LkW6k02jLudhpeIEIenfdymHj1P+Ll J6K9AGwHv5RVu4uS7DR57Nnj5UbgLh5t7TfGvbF0+C3igvXw1vdet24qegxb3ipIncJH sodA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=vPBr428q; 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=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ho35-20020a1709070ea300b0078dcbc9a9b1si1334089ejc.737.2022.10.13.19.11.57; Thu, 13 Oct 2022 19:12:45 -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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=vPBr428q; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbiJNCCU (ORCPT + 99 others); Thu, 13 Oct 2022 22:02:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229511AbiJNCCR (ORCPT ); Thu, 13 Oct 2022 22:02:17 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D2BD183D85 for ; Thu, 13 Oct 2022 19:02:16 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id o17-20020a17090aac1100b0020d98b0c0f4so5192426pjq.4 for ; Thu, 13 Oct 2022 19:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=bFZZy9pvaOE5FXP35cf1kMoA7/k/1JqmLQ8oHebi89Q=; b=vPBr428q2Qxd98OWgc+dKi3IH6tMaEpPpxEBqxTmjml9jPzswHRHD8rE5GQ7b7ouZT zmLZzcINK60zRtbjuHTcwFYMplDN4c21bAUzsseDBxoy34KkBbJkxAh/oBYonDENTLIp mL6xKiyxY69vcrausoP6lPdj6hym19RR0FTc49HmJmYwp28l44kabM7+o13QyImLWfhh nypq3ME2HywOpnH/gzrGcSIPcr1kpUEDkrs3tZn0eCj6jM2RwazxcX0LshmiTyWihioN XoYLXrDXXZQ/tx4nWciizrncH0jfQoqDKuBuXHNC5d+qJCg8z3N0OailkZ+pOsKoXyz2 SiSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bFZZy9pvaOE5FXP35cf1kMoA7/k/1JqmLQ8oHebi89Q=; b=ITalZVJ5YG2d++9Lj3aSulmePpC2lznnq9V9XsiHCVoY+xgFK9IK85QWn1yH9fVAwB 7n+7W7Y5tt3cy9nlH4GmJLeEmo3hwcA607ZnoMn1vD56nruzoGEA85LEC/cV1nO75eK2 JoaAYZnvrrHPSTMn9lY3eeIMO+/6MtDgin/mzm3bt9E6aMbz0qPPP8qDMdyUGRAa9DW4 OqbHDSwaIEv/gSnDdfzFhDdt9vrju8+IHrMzKCdNsMVrL4c7KP8yhmPZOeo6hIyFFp74 yKQCP8mVxet59/JJFdP+DB+XyMrOtDveu+3A8TfC7Zg4J+EDAkMCoQGhu0Ha4F/pq6bc 4/GQ== X-Gm-Message-State: ACrzQf0AAgyj59cQelHQK0IBfKRD5p+wRYRUTL+o5wJzgjFapfeS7FOY xLVWP2Xojby3/oLFpHSTVKh36g== X-Received: by 2002:a17:902:f7cf:b0:17f:9081:a3f7 with SMTP id h15-20020a170902f7cf00b0017f9081a3f7mr2629844plw.3.1665712935855; Thu, 13 Oct 2022 19:02:15 -0700 (PDT) Received: from [10.4.165.47] ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id f15-20020a170902684f00b001769e6d4fafsm497131pln.57.2022.10.13.19.02.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Oct 2022 19:02:15 -0700 (PDT) Message-ID: Date: Fri, 14 Oct 2022 10:02:10 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.3.2 Subject: Re: [PATCH] sched/psi: Fix avgs_work re-arm in psi_avgs_work() Content-Language: en-US To: Johannes Weiner Cc: Suren Baghdasaryan , quic_pkondeti@quicinc.com, peterz@infradead.org, quic_charante@quicinc.com, linux-kernel@vger.kernel.org References: <20220913140817.GA9091@hu-pkondeti-hyd.qualcomm.com> <20221010104206.12184-1-zhouchengming@bytedance.com> <46c6e1cc-77d3-eac1-fa18-deed2bac4a0e@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 2022/10/13 23:52, 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. Ok, will move these resched logic to the end of get_recent_times(). > >> @@ -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? Yes, only psi_avgs_work() use this to re-arm now, I will add this check next version. Thanks.