Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp153993rdg; Tue, 10 Oct 2023 06:54:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgSjyTk1+g71fFhwdLVbN0KCyEwZpmwb/U7DOgZ0Rukvwg9r2aStPzi73GQIlDaG6Z0kSv X-Received: by 2002:a05:6358:999f:b0:140:f6ab:b11e with SMTP id j31-20020a056358999f00b00140f6abb11emr20548445rwb.28.1696946090226; Tue, 10 Oct 2023 06:54:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696946090; cv=none; d=google.com; s=arc-20160816; b=K2HaJP6tf3Fz4F4Kqladf3yIvjOmBOHWjd7X+kNmldKu1GV4NAtpq8zJVzO9i96xca Dz3ZI0CMlC5/EuJzPSzbzV5W8DC4KkaU1yXP+S+MAcWLIH+FEFAUzzcuzG9PEl6j4W2p sYN0tY7B1XHzvrEr7v7kCCCmkoe2KFxo7pNjwE93TOdbIXA+tHEuwpPmWeVelay13w8o 6MRiAEUh0X1+hATpWQRJHX8KLFNtE+sCjGEOC8OO456DON5RL29XG7onVNRCtaxixaXo ic0+m+7ieKLAiiSfXXYD1qtdlWNDBL+JKdrI56cDBgwe5nwFiGVhv+Fo6MVCCu/74Jp2 oeeA== 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:date:dkim-signature; bh=/Q2326nbgNVkzW/VEHSwQCD8IL326flLiX2/oxCqN0g=; fh=yy0bxSsti0WQrv7TpuYs78nrsThj7DPol017JIm/t7o=; b=OdYEZX/20/0sK7zps3w8aYJXbYaSUja9K7Wj+x2NnyqhPEZts+RyrEkH5G36UrPRfp ZS7KPJAOvXjs1j0FCa4x50nvzBdH+tUBWv2hEGPzh2vU6BUW6oMIcimYmqNfwGxtUAow t2Ea9sA9EGgoG3B3SNXVWmgnK7W4jyV7ENV2miBeKx9y02pTCR6Nxy/LPMAK0CJXyFSx eQCKKZR3sSFSxepc+qJ/bcbE/ME4+d8pom3ToC9BxA/ePHrlWmLmAU+34plRLaphpvPU JNNETNrZiAmJWSJESWmLYIx9s5MwkbZS2n90PLAvqX1jeJGghlOu5fwabmDoi/h0EG1K jNfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vwbk4OYT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id e8-20020a636908000000b00577a083624csi11866940pgc.89.2023.10.10.06.54.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 06:54:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vwbk4OYT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 0B13180CF535; Tue, 10 Oct 2023 06:54:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232498AbjJJNy3 (ORCPT + 99 others); Tue, 10 Oct 2023 09:54:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232465AbjJJNy3 (ORCPT ); Tue, 10 Oct 2023 09:54:29 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F9F39D; Tue, 10 Oct 2023 06:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=/Q2326nbgNVkzW/VEHSwQCD8IL326flLiX2/oxCqN0g=; b=vwbk4OYTkj+i5hVlzwFJfLP7V8 4Wca/Me2pvYsVPi5UmFxhBkFS2Rli0Hl4cs3XiY/gVPYh2aix9MnSTDlNIJ1ZNSSubRiUeGiKI4Fd 2uCUvvOpNsOvFMl5ogtHz4C5x1aZ6HSBk5DICSeyAwynTDnoBUftyKtkB6W5p0mFppUxUnSzIN/1N +pgD6/DpPlv1Y08Yrn8y+1qnByWbjf0VmLnW6qiy82RHDXOmZg9dgpk7g6xYtBRVi87Hlz0lzSSye 8BZOoxEinlmAC2yhdWhncDkg+yQ+sAAalCckfYRhlMdHLmcSgsGAdJ0NETgV1px/iZcwY7oOnzzUQ wnfhJOkw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1qqDB6-004xnI-KK; Tue, 10 Oct 2023 13:53:40 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 4E225300392; Tue, 10 Oct 2023 15:53:40 +0200 (CEST) Date: Tue, 10 Oct 2023 15:53:40 +0200 From: Peter Zijlstra To: Hao Jia Cc: mingo@redhat.com, mingo@kernel.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Igor Raits , Bagas Sanjaya Subject: Re: [External] Re: [PATCH] sched/core: Fix wrong warning check in rq_clock_start_loop_update() Message-ID: <20231010135340.GK377@noisy.programming.kicks-ass.net> References: <20230913082424.73252-1-jiahao.os@bytedance.com> <20230928114159.GJ9829@noisy.programming.kicks-ass.net> <979f948c-7611-b137-a06a-ca09ff63f919@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <979f948c-7611-b137-a06a-ca09ff63f919@bytedance.com> X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Tue, 10 Oct 2023 06:54:46 -0700 (PDT) X-Spam-Level: ** On Sat, Oct 07, 2023 at 04:44:46PM +0800, Hao Jia wrote: > > That is, would not something like the below make more sense? > > If we understand correctly, this may not work. > > After applying this patch, the following situation will trigger the > rq->clock_update_flags < RQCF_ACT_SKIP warning. > > If rq_clock_skip_update() is called before __schedule(), so RQCF_REQ_SKIP of > rq->clock_update_flags is set. > > > > > __schedule() { > rq_lock(rq, &rf); [rq->clock_update_flags is RQCF_REQ_SKIP] > rq->clock_update_flags <<= 1; > update_rq_clock(rq); [rq->clock_update_flags is RQCF_ACT_SKIP] > + rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); > * At this time, rq->clock_update_flags = 0; * Fixed easily enough, just change to: rq->clock_updated_flags = RQCF_UPDATED; > > pick_next_task_fair > set_next_entity > update_load_avg > assert_clock_updated() <--- > } --- diff --git a/kernel/sched/core.c b/kernel/sched/core.c index a0a582c8cf8c..cf9eb1a26c22 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -5357,8 +5357,6 @@ context_switch(struct rq *rq, struct task_struct *prev, /* switch_mm_cid() requires the memory barriers above. */ switch_mm_cid(rq, prev, next); - rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); - prepare_lock_switch(rq, next, rf); /* Here we just switch the register state and the stack. */ @@ -6596,6 +6594,7 @@ static void __sched notrace __schedule(unsigned int sched_mode) /* Promote REQ to ACT */ rq->clock_update_flags <<= 1; update_rq_clock(rq); + rq->clock_update_flags = RQCF_UPDATED; switch_count = &prev->nivcsw; @@ -6675,8 +6674,6 @@ static void __sched notrace __schedule(unsigned int sched_mode) /* Also unlocks the rq: */ rq = context_switch(rq, prev, next, &rf); } else { - rq->clock_update_flags &= ~(RQCF_ACT_SKIP|RQCF_REQ_SKIP); - rq_unpin_lock(rq, &rf); __balance_callbacks(rq); raw_spin_rq_unlock_irq(rq);