Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2248918pxb; Mon, 23 Aug 2021 15:58:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxI8QyCLIHpuVquLJePruaodJ6BR/P5g0Qm5Q+1Hlgc0FdSm5GvPPc6pSfzKAS6Gr1j4RQY X-Received: by 2002:a05:6602:1246:: with SMTP id o6mr3443082iou.173.1629759523879; Mon, 23 Aug 2021 15:58:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629759523; cv=none; d=google.com; s=arc-20160816; b=b4yW+rVluSKwO1JfPDYW1LeHCZy78Ok+fpH/Bids2PFFgxIQV6DwfpmoXy4xe7EL3O LeemykmCPOsUl1I63Pn0mmZJIBdjJlZucA30Q85uxM8v6kbVuM7WKJEXvlhA3vQb8+Im NbBrTqIXnG25cPpYY4yQqjtOPfurez1mGa3efoRln5Z7R4Gla3r1/hNcxl9WPhl42ZIv ldchtvS0jGTZ01qYgLfo89Qq8Q0OhLAwvlvChrH2gcEkhO1FfBwoGMDwuUzvptpIDWb4 4K7zW5P0BTRgYgn+wlZqt8MA/7yqoPwOYWqo0gkeZxQDfOkbUJntrEerJLP9B+1A0V/F OLeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:dkim-signature:date; bh=z2CxI1VfBsnL0p5UbvwsEu/xbia02T68QPuq9M2KuVA=; b=j6Tb7v3TB9E74fne6eW7GABtyhes+qR2RvQoJix/n5cUgmFoXQEVD5i8rSh/RmKg9e tKvno/NgRO/EieGw2AZe2Rm3Fuwjgyp/kYqIYiKf7dpRKj2FL/uLNwAU/5w0JcEON2LA G7ItVJ0wzfaVzrfYY4RVzRPgjYhsruPiRzj3k2ZqCBh92PB0mokPctBfaQkm9qu7GdnK iOkBJTeOw0M6nCFDhDQl4+/HyyG87jgbsW6pZ8tjbM2ohTV7hRWIVZiRhhuZdwC+UbAw 3aIDTRzmTb1qb2dg0ho7gDDAKK0alQ/ul8SQQ9eNjHo5OLDIp+CJTXZpmrS61ds6auAC NpLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=tdlEmE8n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g7si19593335iov.41.2021.08.23.15.58.32; Mon, 23 Aug 2021 15:58:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=tdlEmE8n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233178AbhHWW5k (ORCPT + 99 others); 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