Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp506740rwe; Wed, 24 Aug 2022 04:58:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR7IEiXtzutvmxcnFUTR/6wv3GuX6GUXu6QdHhbgc60+ReHQ7HWlreUPUXOPVY+XqxYD/E00 X-Received: by 2002:a17:90a:1c02:b0:1e0:df7:31f2 with SMTP id s2-20020a17090a1c0200b001e00df731f2mr7783869pjs.222.1661342313818; Wed, 24 Aug 2022 04:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661342313; cv=none; d=google.com; s=arc-20160816; b=k/61ivdculaoGo7E7EOM360FynS3yX4xY+28XOlc5UtMNckQSrfu+5WPTO5OMUjdSQ Pf4cEdiaIBuxzhiFOsyIwT0UkGCL07rSVsUDuo84KyYmrwf6co4csWCEa3cM/cwNSkbL 0q1r8NtBSCecQPHDv2sk7Tn798LdeWzk5K4bwv9I4jgb0Qc8ASoUVeFyrb32lV37hQOu bcGqRY4Gqx18DcQMknGmhCWWy6sQj9/hrTyUCd/30sZ7TD9An8kE9Cno6sa3uS02kuXz m3LffQpJVEFfMVtKwpofkM9B/lzj/Xz2Gux20cbDr6xpr6rH/xI36dRz9aQRLlbmjNJx Npuw== 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=mdfwmPodCkN/tga61cvp2E/By8brPAPT4bch4OmZBrY=; b=M4hJQtt6StFscX09odxvDUPWhqItx8SIIOGM1cAM5mVgsB3K/8SrIu11pyc4O1DNCw hW9wHLoeOOWcz7HuRdxUUvZIdPG4SxEimgqNxEpq63FLzi7LyGytvs6XVyECqekYgGp7 3+FHeuAe1n1Ss4/wgJtUZPvqN3K7EKD/wghieQNWVrPl0KBNmt87JBDehDZfZIzXpxSs 0j4hIyxwkevxFoL34+dMcmXWE9UEPvL8MpSvv2chLmBmsydWAB004qQGK35n075W164N LzzXbdtQCxjZJ2RZ4AJibBPvcDmqIyyNlcgFacWRTrxu3dx+8zm13L41S1C3HfZwPQSk RR9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=jQkEZX35; 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 n9-20020a17090aab8900b001fb29d5d2easi1058896pjq.67.2022.08.24.04.58.22; Wed, 24 Aug 2022 04:58:33 -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=jQkEZX35; 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 S237112AbiHXLyH (ORCPT + 99 others); Wed, 24 Aug 2022 07:54:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234085AbiHXLyG (ORCPT ); Wed, 24 Aug 2022 07:54:06 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 121DA8688E for ; Wed, 24 Aug 2022 04:54:05 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id q63so575334pga.9 for ; Wed, 24 Aug 2022 04:54:05 -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; bh=mdfwmPodCkN/tga61cvp2E/By8brPAPT4bch4OmZBrY=; b=jQkEZX35Ws1c7ZeEwSoJBemqsqFfAypyELXqRGaM1Iwi5lyiq2xztSyATJfhvxF75Z ul8dBoqZHEckEFGA2Vj+QqOizPpteP5iRhGYBJ5PgqcPGaXIQs5ZopwVs6VuSY1l5tRg 3Iz7Q0hkGTSLDWRi2xN7rYUTm402YSXBbyMt8JPsRE032tVM8R9dHI40vgO74WPOSuv8 l25FKg7I2R437aLqahE1+UG+kYgpxhIf1V7fiRgSC94VISztjWh5wCUYNaoDtWjm2QGX eRxMkA21nMzsbRc6hdRrJqqfJ8QBfsu0aKk1Ldf41vLMtxNHZFFgbr58kBl4gPrKSG0S oh2Q== 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; bh=mdfwmPodCkN/tga61cvp2E/By8brPAPT4bch4OmZBrY=; b=6a4y1Y/1R9O2DTSYV2SZK/8BSOXFKaJUNMrUihlAr+Lr28nrZSJt0qjK7kpo2fZast Ch2Q84Q3YTUiDu+pP4ewRn/tUUNICVqkn/A9F4OcpCu5C7olri+9gskrIqGLFgZ8xoAS J4EVcoyG5qmN63A4+MNhn+292ijZCsmQSCKt/CcW9MaUMNGWl80svzThI+FPZ6WYEvHu +sGHwZDkn/BqC1nOfvsHNx0h1GBUox5Nun6ZBJGdQgZSG8YMrAsq3OHw6r8BziFqGpCK /74wFmuwKWolxTwd53E6CgBgPs38+6ITRjqi69Z75bqqSlKW+p+1Jxv7JjOrgXoKwuIU M2Bg== X-Gm-Message-State: ACgBeo1qzSMiRnvsFTTMhDR62/7Ly4zgUvNSLWcImlFtrTbv3cljwEUm IXJFSl2hFDESikOiQsRSmvdqWw== X-Received: by 2002:a65:6c10:0:b0:429:4a5:a4d0 with SMTP id y16-20020a656c10000000b0042904a5a4d0mr24569071pgu.614.1661342044601; Wed, 24 Aug 2022 04:54:04 -0700 (PDT) Received: from [10.4.208.12] ([139.177.225.228]) by smtp.gmail.com with ESMTPSA id g126-20020a625284000000b0052d7cca96acsm12750758pfb.110.2022.08.24.04.53.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Aug 2022 04:54:04 -0700 (PDT) Message-ID: <911cd0fc-0027-6da5-767a-fea4c7731c81@bytedance.com> Date: Wed, 24 Aug 2022 19:53:52 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.2 Subject: Re: [PATCH v3 07/10] sched/psi: add PSI_IRQ to track IRQ/SOFTIRQ pressure Content-Language: en-US To: Johannes Weiner Cc: tj@kernel.org, mkoutny@suse.com, surenb@google.com, gregkh@linuxfoundation.org, corbet@lwn.net, mingo@redhat.com, peterz@infradead.org, songmuchun@bytedance.com, cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220824081829.33748-1-zhouchengming@bytedance.com> <20220824081829.33748-8-zhouchengming@bytedance.com> From: Chengming Zhou In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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/8/24 18:46, Johannes Weiner wrote: > On Wed, Aug 24, 2022 at 04:18:26PM +0800, Chengming Zhou wrote: >> @@ -903,6 +903,36 @@ void psi_task_switch(struct task_struct *prev, struct task_struct *next, >> } >> } >> >> +#ifdef CONFIG_IRQ_TIME_ACCOUNTING >> +void psi_account_irqtime(struct task_struct *task, u32 delta) >> +{ >> + int cpu = task_cpu(task); >> + void *iter = NULL; >> + struct psi_group *group; >> + struct psi_group_cpu *groupc; >> + u64 now; >> + >> + if (!task->pid) >> + return; >> + >> + now = cpu_clock(cpu); >> + >> + while ((group = iterate_groups(task, &iter))) { >> + groupc = per_cpu_ptr(group->pcpu, cpu); >> + >> + write_seqcount_begin(&groupc->seq); >> + >> + record_times(groupc, now); >> + groupc->times[PSI_IRQ_FULL] += delta; >> + >> + write_seqcount_end(&groupc->seq); >> + >> + if (group->poll_states & (1 << PSI_IRQ_FULL)) >> + psi_schedule_poll_work(group, 1); >> + } > > Shouldn't this kick avgs_work too? If the CPU is otherwise idle, > times[PSI_IRQ_FULL] would overflow after two missed averaging runs. If the CPU is idle, task->pid == 0, so no times[PSI_IRQ_FULL] would accumulate? I was thinking if task->pid != 0, avgs_work should be active. Not sure, maybe I missed something. > > avgs_work should probably also self-perpetuate when PSI_IRQ_FULL is in > changed_states. (Looking at that code, I think it can be simplified: > delete nonidle and do `if (changed_states) schedule_delayed_work()`.) ``` collect_percpu_times(group, PSI_AVGS, &changed_states); nonidle = changed_states & (1 << PSI_NONIDLE); if (nonidle) { schedule_delayed_work(dwork, nsecs_to_jiffies( group->avg_next_update - now) + 1); } ``` Yes, changed_states include PSI_IRQ_FULL, here we only check nonidle = changed_states & (1 << PSI_NONIDLE), so it will not restart if only PSI_IRQ_FULL? If use `if (changed_states) schedule_delayed_work()`, avgs_work will self-restart when only PSI_IRQ_FULL changes? Thanks!