From patchwork Mon May 15 06:38:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hao Jia X-Patchwork-Id: 93893 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp6720023vqo; Mon, 15 May 2023 00:02:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5c8YBjkAJVX7nq1Rey/VvUNZHhJ+sdSPpwj/BiHt3dJNuN6igigPQltU2lFg2uR05IF2+3 X-Received: by 2002:a17:90a:f8d:b0:250:85ba:6c3d with SMTP id 13-20020a17090a0f8d00b0025085ba6c3dmr24908318pjz.6.1684134157122; Mon, 15 May 2023 00:02:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684134157; cv=none; d=google.com; s=arc-20160816; b=sex7wPR4cQ9bfBQzkLtH7yZm5QOzlso4jWIiyJO2cyva4kNsI2xOrdLa26qZa3BZOG 1Ho5T9dfvEeBk6LNjteeO5GFsBS63ylBuj6tVUgwcxI9G4bKkylMm8x3k6ukbcOyqExC o+2N/nZhSc2e9nxNbaMEJSQDvgc18xwxR+5RdvmEOscp2oXuisiEQwVvf8qiZftpJWBt eHo6UHD9u7A78AwJpS7+ngp6/brdSQZQ8HQ9zlhUpnqSoc3848MuEfCpRqrcv5HThGUU ocihNIJy4gMitfNaeIGGFZuHfWS+XcmbkKVDETpGVM8udjlLMVr7W/citgsnbRGFSjZ4 scVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MbGpG4ZAOaq7Hlh8d6bFS/m3vJCuvL29YZwPCpli9B8=; b=bz3FOmz+dxL7US8/HB5bUryocgAw3uJ+NYDZyH2MMvZlPU2u+NvU4KO2fGt5emdwQU txHOl1lHVQ48uvPkOCViO+D7O61K+zP6KV8FMN8sFRx8GBMVpzUMR92G5JAMHJZ43dEB +wXMB63s8EA/fbuiL/kHBOy9/kvRFeKinwMnkAxruA1bYuM5D6H5mwz/5sqhiqJwmlYj qBi029I4PZTUQSa5cMEZoOkuk2oeUhHEscuDIu6mV77X5gfroNyRu4gm5vm/mczPQcV3 1ZZIhu0VycpqL5NssaKF/O6EBJElM2+4LDzsOjYxuk1F9phM/96lyNN/lC796ZpNlX6a QPEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance.com header.s=google header.b=TmDtPDc6; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pt6-20020a17090b3d0600b0022bbae722fcsi15780751pjb.1.2023.05.15.00.02.23; Mon, 15 May 2023 00:02:36 -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 header.s=google header.b=TmDtPDc6; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240013AbjEOGjo (ORCPT + 99 others); Mon, 15 May 2023 02:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239976AbjEOGjg (ORCPT ); Mon, 15 May 2023 02:39:36 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41A6F1BE4 for ; Sun, 14 May 2023 23:39:12 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-52c690f7fa4so8421363a12.0 for ; Sun, 14 May 2023 23:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1684132752; x=1686724752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MbGpG4ZAOaq7Hlh8d6bFS/m3vJCuvL29YZwPCpli9B8=; b=TmDtPDc6nVDFKFdY0PRjJD3KjNUkAvZ/MFPGIZRevSxWptFajvFeIoBK2AmZdC0qMD wKGjXMjTq2bKBbovs8tI6qlAWuTS2oYndwwu+LXCvAzpAV4XUzV6cBAPWg6qTteyGOtZ oB1y0LDUJMcWmcnVCuQJxOf8UajkJqTqdV2VqD3xSUzygn7AZiCcaAyvCBuarO6S+rA1 TJ2ZG4PtNX6fIDF5cDwKPUSQFPJUHPV1daBPtT5g41QhQ8AIyXrMzkKW8DwCIqXeP8sC nIqeQqyhhZY8SX1Fa+AmQVTv6cNvHASROdvY3wMIFwGlCmOwfUQr5erweC/qWrL/MHJ9 0qKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684132752; x=1686724752; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MbGpG4ZAOaq7Hlh8d6bFS/m3vJCuvL29YZwPCpli9B8=; b=WXGhnurCWLeSCeK+AqgV/3y1UnyAm8DvdW6dEIjxqC/xLtONEY856Kmk2GbNIW8qvB uGNlBLrf/zu8dyaYGDdN6LhKDPibRZ0gXi7LpFu3irpT6NM2aHzVmFMPrmg4j0Yt6JCE 3dsnQX5J53dQSB60ErT0FS/CFsc1PTMQe/mezvCKc2JXCayRPeldaLq/cA+YzQA1ldS+ 9MK9Pv4zQ+QMoS19wy7EcoDnTeH9u2OXLF1wxyiyno0kSgv5ZgqdfABB45yZbZvKOFXc xOgiAdOT1/sCkNIERwMVVSIHHFrVPIWZguVmQZ/pMavC5JZjPYNvDIehOhgjYzL0TGKA Lv3g== X-Gm-Message-State: AC+VfDygKtI5GsPurw91nJ7hOe0wmfLIs5mS5kPsgJImFpvq4ap/LOpj NTHW4sZhnMlqnP+yaCClWOvHLQ== X-Received: by 2002:a17:902:b696:b0:1aa:f203:781c with SMTP id c22-20020a170902b69600b001aaf203781cmr28759823pls.44.1684132751752; Sun, 14 May 2023 23:39:11 -0700 (PDT) Received: from C02G87K0MD6R.bytedance.net ([139.177.225.228]) by smtp.gmail.com with ESMTPSA id t1-20020a170902a5c100b001ab01598f40sm12608543plq.173.2023.05.14.23.39.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 May 2023 23:39:11 -0700 (PDT) From: Hao Jia To: mingo@redhat.com, peterz@infradead.org, 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, mgorman@techsingularity.net Cc: linux-kernel@vger.kernel.org, Hao Jia Subject: [PATCH v3 2/4] sched/core: Avoid double calling update_rq_clock() in __balance_push_cpu_stop() Date: Mon, 15 May 2023 14:38:46 +0800 Message-Id: <20230515063848.77947-3-jiahao.os@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20230515063848.77947-1-jiahao.os@bytedance.com> References: <20230515063848.77947-1-jiahao.os@bytedance.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765942657866307356?= X-GMAIL-MSGID: =?utf-8?q?1765942657866307356?= The WARN_DOUBLE_CLOCK warning is triggered during cpu offline. ------------[ cut here ]------------ rq->clock_update_flags & RQCF_UPDATED WARNING: CPU: 17 PID: 138 at kernel/sched/core.c:741 update_rq_clock+0xaf/0x180 Call Trace: __balance_push_cpu_stop+0x146/0x180 ? migration_cpu_stop+0x2a0/0x2a0 cpu_stopper_thread+0xa3/0x140 smpboot_thread_fn+0x14f/0x210 ? sort_range+0x20/0x20 kthread+0xe6/0x110 ? kthread_complete_and_exit+0x20/0x20 ret_from_fork+0x1f/0x30 To avoid this warning, we remove update_rq_clock() from the __migrate_task() function. And in order to avoid missing rq clock update, add update_rq_clock() call before migration_cpu_stop() calls __migrate_task(). Signed-off-by: Hao Jia Reviewed-by: Vincent Guittot --- kernel/sched/core.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 944c3ae39861..2bcf6a8e71fc 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2398,7 +2398,6 @@ static struct rq *__migrate_task(struct rq *rq, struct rq_flags *rf, if (!is_cpu_allowed(p, dest_cpu)) return rq; - update_rq_clock(rq); rq = move_queued_task(rq, rf, p, dest_cpu); return rq; @@ -2456,10 +2455,12 @@ static int migration_cpu_stop(void *data) goto out; } - if (task_on_rq_queued(p)) + if (task_on_rq_queued(p)) { + update_rq_clock(rq); rq = __migrate_task(rq, &rf, p, arg->dest_cpu); - else + } else { p->wake_cpu = arg->dest_cpu; + } /* * XXX __migrate_task() can fail, at which point we might end