From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3684C4338F for ; Mon, 23 Aug 2021 22:56:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B5B0D613A7 for ; Mon, 23 Aug 2021 22:56:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233222AbhHWW5k (ORCPT ); Mon, 23 Aug 2021 18:57:40 -0400 Received: from out2.migadu.com ([188.165.223.204]:25495 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229632AbhHWW5j (ORCPT ); Mon, 23 Aug 2021 18:57:39 -0400 Date: Tue, 24 Aug 2021 06:57:46 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1629759415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=z2CxI1VfBsnL0p5UbvwsEu/xbia02T68QPuq9M2KuVA=; b=tdlEmE8n/LIipOqtWWf11vVdqws5X54oGnb2hg9CITwdu72udesgOHRcwI2B8Dj9jZlySH hF2uHX4+uWMoXEVafChNuX9mvgxFZL5oLRPdRjGFz09Jr3+RbqO/pzsmJOrpvcG94Vu5je w753EHR0KOgDX3GOiZjS4Qn3tdYdiJo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Tao Zhou To: Vineeth Pillai Cc: Peter Zijlstra , Josh Don , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Joel Fernandes , linux-kernel@vger.kernel.org, tao.zhou@linux.dev Subject: Re: [PATCH] sched/core: fix pick_next_task 'max' tracking Message-ID: References: <20210818005615.138527-1-joshdon@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: tao.zhou@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vineeth, On Mon, Aug 23, 2021 at 04:25:28PM -0400, Vineeth Pillai wrote: > Hi Peter, > > > > > Here, we should have instead updated 'max' when picking for SMT-1. Note > > > that this code would eventually have righted itself, since the retry > > > loop would re-pick p2, and update 'max' accordingly. However, this patch > > > avoids the extra round-trip. > > > > Going with the observation Tao made; how about we rewrite the whole lot > > to not be mind-bending complicated :-) > > > > How's this? It seems to build and pass the core-sched selftest thingy > > (so it must be perfect, right? :-) > > > Nice, the code is much simpler now :-). A minor suggestion down.. > > > - for_each_cpu(i, smt_mask) { > > - struct rq *rq_i = cpu_rq(i); > > - > > + /* > > + * For each thread: do the regular task pick and find the max prio task > > + * amongst them. > > + * > > + * Tie-break prio towards the current CPU > > + */ > > + for_each_cpu_wrap(i, smt_mask, cpu) { > > + rq_i = cpu_rq(i); > > rq_i->core_pick = NULL; > > > > if (i != cpu) > > update_rq_clock(rq_i); > > + > > + for_each_class(class) { > > + p = rq_i->core_temp = class->pick_task(rq_i); > I think we can use core_pick to store the pick here and core_temp > might not be required. What do you feel? You're right. The @core_temp load the class pick, the @core_pick is the final pick(class or cookie). Using @core_pick to store class pick first and then the final pick is right and save the bytes) but just a little not clarity from my end :-) > > + if (p) > > + break; > > + } > > + > > + if (!max || prio_less(max, p, fi_before)) > > + max = p; > > > Thanks, > Vineeth Thanks, Tao