Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2073962rdb; Mon, 9 Oct 2023 11:33:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERmh4q5n193IG+7Xa6Ub0EIHh3nwilw60KrSEK5EN70uW3O4nCS7ffm8UCfxXua2bFckw4 X-Received: by 2002:a05:6a20:7d9c:b0:129:3bb4:77f1 with SMTP id v28-20020a056a207d9c00b001293bb477f1mr16983884pzj.0.1696876438115; Mon, 09 Oct 2023 11:33:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696876438; cv=none; d=google.com; s=arc-20160816; b=ce35IgVHlvSTgO3Op0aJq56oUvXzaorKXy8ftKNVjXN/p8aWM4NcQV9vgiivmk8jVm EevnqOEyoGfjNGxO1MjwShhZfN8NOVtNUZSw2MyZrxRkmP0j++zfh0PDhtoW9XcBUb49 zsZnckuZsJPJPWw+BKyEgJO9+ROkEavu3Ect2lT1BNlt/G7eojVNV9Lm4ub+E26Ffkcg pv+jdo4Xf3e3FM/SvjGA+2w36klAF8urAI/5QGDlmUNqft1IhlzH7bxnmeUvgH7Rw/Rt 9srm+50zj/gPWUN9dqNiicHoWbtRuMSDTsFzixQpraGYqWSP1/ABYpyu2a3oWCEjizV5 wt2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=hbawRUEwL9/zR8hpVKzzXxK+1LBrSHSBk1bYuOQZmBA=; fh=TYbYnJcx3bCYUdQWVHfP1vuLCYS/o40hTmEPMMOgU64=; b=Q+WtgPIgzP01LA5y9iBo86xsybxwx6PzVFWGwErOFWvTbrHYPqzEVqlt2PbEMmsBBq sRLi0WrqOTtgs5SUlg2ao9jeYd1SV7u+AWrHYNq5SSoQFc6jD25cyjgNrOntAiplC5Iz eueeVb5RNnNP5AGhStlA7fBn778zf5oACCD4/15LBC1BfQHB67MpsjM0JEi/8Wa1qNjm +TQF2pgO70vqm9wFth3odeLQX3SE6TXE6bNBMH+EeqiKusq7MrwCNJMzaIVKya/WELcK TKRD0/fdGojaA6jVErRMfrMjnGWS6SMv/n8bJ3THWpdx0yJHtils5+PRDintx7PhGoke dfow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YZEz0bkt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id z9-20020aa78889000000b0068fef37e5bdsi8096546pfe.244.2023.10.09.11.33.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 11:33:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=YZEz0bkt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id E8BF8801B322; Mon, 9 Oct 2023 11:33:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377350AbjJISdp (ORCPT + 99 others); Mon, 9 Oct 2023 14:33:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376281AbjJISdp (ORCPT ); Mon, 9 Oct 2023 14:33:45 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182B2A3 for ; Mon, 9 Oct 2023 11:33:42 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c6185cafb3so296995ad.1 for ; Mon, 09 Oct 2023 11:33:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696876421; x=1697481221; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hbawRUEwL9/zR8hpVKzzXxK+1LBrSHSBk1bYuOQZmBA=; b=YZEz0bktkrehiO+IUVn17qS+9zbtJodkAWUBOg/+dLNinbFifPM7YKm+fQA5Oue+LW DLccQM/VQ9WxaNoEqZdMokt8fDG+j8Po8prHUJodKDBCVIVazCBaLPgRXk+alsZpok+h FBPt4c0q6kLjvvsAMal+IEAiVzrXtiwBnAjW6ypXns2gyh63Y9PvEncyAkzH5jh/ucu6 8d2oVFlJBIfBy0azSkIcmjwTnPjmze+CQVqtbhT3iw+lR7qxT+nyegIxCHTEK2Kz+3Ub ICnFwNkT/PxuVR3F5RPY7s6Ezq0wdJuzwloOJb/2N/M8dT9Pfw1r2SOJI3aQXzliWKz9 ouEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696876421; x=1697481221; h=content-transfer-encoding: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=hbawRUEwL9/zR8hpVKzzXxK+1LBrSHSBk1bYuOQZmBA=; b=qCS1olhVzY8f3XfhyI30lnePFL24tqEhLOS7CqAx2Ov/ow+mt4hzXbndZzfL9s5GxQ bbt7YgBbkvn/kcNfaZM99Qp8DnseoWldg9ZzlzXjSFvJAoH3uBH4y0Y4NN8jE+jiZZ6e rNHYNlu0RQ5v5yt9L4rzwlQXZ/Fn7/pMkZ9APOcuXJF8Ji3tWsvKxObaoAxbzHv15OY5 qtCvF9aqwtPO157czu2aw/Y78GFQ9T/Sqvx9NLGPEiHkRNuOiHvbtOOnFhh1tLPwp9Tv b78VGW8owwqLE1x8OtrHXLT3ZpxiOiRHJ/sfXrhCXWD7Eyw4cw5ENCMeXEQiy/Pjk0tl lD7A== X-Gm-Message-State: AOJu0Yx1J/h110g0tRRBQmbswkQ5Fb4fvj5/Tk4ThQ/X+6VJfeMgAvfB ELSXuMvVPWAsz+/9DyzvaBjtKdFaN2qtoqLBRwDfQQ== X-Received: by 2002:a17:903:183:b0:1b9:d96c:bca7 with SMTP id z3-20020a170903018300b001b9d96cbca7mr744200plg.25.1696876421161; Mon, 09 Oct 2023 11:33:41 -0700 (PDT) MIME-Version: 1.0 References: <20231005161727.1855004-1-joel@joelfernandes.org> <20231008173535.GD2338308@google.com> In-Reply-To: <20231008173535.GD2338308@google.com> From: Vineeth Pillai Date: Mon, 9 Oct 2023 14:33:30 -0400 Message-ID: Subject: Re: [PATCH RFC] sched/fair: Avoid unnecessary IPIs for ILB To: Joel Fernandes Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Suleiman Souhlal , Hsin Yi , Frederic Weisbecker , "Paul E . McKenney" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 11:33:56 -0700 (PDT) On Sun, Oct 8, 2023 at 1:35=E2=80=AFPM Joel Fernandes wrote: > [...snip...] > > The patch does make _nohz_idle_balance() run more parallel, as previous= ly > > it would be generally run by the first-idle CPU in nohz.idle_cpus_mask = (at > > least for next_balance updates), but I think it's still SMP-safe, as al= l > > key data structure updates are already rq-locked AFAICS. > > One thing I am confused about in the original code is: > > tick_nohz_idle_stop_tick() is what sets the nohz.idle_cpus_mask. > However, nohz_run_idle_balance() is called before that can happen, in > do_idle(). So it is possible that NOHZ_NEWILB_KICK is set for a CPU but i= t is > not yet in the mask. > > So will this code in _nohz_idle_balance() really run in such a scenario? > > if (flags & NOHZ_STATS_KICK) > has_blocked_load |=3D update_nohz_stats(rq); > > AFAICS, this loop may not select the CPU due to its absence from the mask= : > for_each_cpu_wrap(balance_cpu, nohz.idle_cpus_mask, this_cpu+1) > I have traced this a bit further. As Joel mentioned, the nohz.idle_cpus_mask shouldn't contain this cpu when nohz_run_idle_balance () is called from do_idle(), but on tracing I have seen that it does have it mostly with HIGHRES. And I feel this is a bug. We call nohz_balance_enter_idle() when we turn off the tick, but we don't always call nohz_balance_exit_idle() when we turn the tick back on. We call it only on the next tick on this cpu in nohz_balancer_kick. If a wakeup happens on this cpu while the tick is off, we re-enable the tick, but do not remove ourselves from the nohz.idle_cpus_mask. So, ILB will consider this cpu to be a valid pick until the next tick on this cpu where it gets removed. I am not sure if this is intentional. If this is a bug and we fix it by calling nohz_balance_exit_idle during restart_tick, then we might not probably need NOHZ_NEWIDLE_KICK flag and could use NOHZ_STATS_KICK as there will not be any overlap between nohz_run_idle_balance and nohz_idle_balance. Thanks, Vineeth