Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5255498imm; Tue, 31 Jul 2018 08:00:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdROuWHUwPNytisPEb6rsUwkH0RffFr6UTxnHji60FFpIsUeNVZVu4TnlVMwAlgELm3jfjv X-Received: by 2002:a63:3c0c:: with SMTP id j12-v6mr20510389pga.440.1533049238754; Tue, 31 Jul 2018 08:00:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533049238; cv=none; d=google.com; s=arc-20160816; b=FxnWsVo4SvEPvKgm55Yw4TG33P8CRw2saujkK1FmEUH1nxf8HSdTgxkbejxvl0+Nz0 NUbXQ6Z67tPg+baeMpX5s2cO17hulastgWEuuL8RBUiM9orzhuUXTiFZeR7RZSReTQ1b cqAULC4m9B124vyRjigB5Cdarozu0mSeZwc6BBNfwu2QL3XNqhHzaVCn3j4dN+0o62Wi u72a3uNnY5OEaiYaTrm5ZR8qez873oSGkMmJBadb4QpjiGEudgap6IJdxdlq2tgaBMuO PuPpgtO0Xuzyb9ipqtOqV6hKTw7eR7+ADDTH80PJZTzxy7Z6l3ONgr2M23kRNiOCfidv yW7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject:reply-to:arc-authentication-results; bh=zrZ/We5UO3A+hn72ftFEjIXLrHkXrkXbGwrTLziYP7c=; b=oHQCVqv2h1+A3/38v7EBrMwBobkkiQFQUdN4F+R/cQ+T5Xs4mlG+oqltLOydHzqf4i JcFPxISwMw0HN/EWPFSVJpY/5LKdXEdwBFGyicWTHzFJJ9BkcaG1m566l5AqSAtu/07F 9vit7MTOqUkwj6VfoS0GJ8asGa7jn+/Fy7t9vquoPqOviErx3ktk2CsumczHpsBwMUMG LzZTPF/g8nuGeLPMgL5LiF1FvGqxfm5TdnKJ66E18+Yvt0liAb/c+X8d3g0wy4KOnKTb z+RQv/rcNvghv32Cwqn9ISB7O3eMOh8EBHzTfJctDarC5Pn6+oiQ6RhUDMoFsc0zmiLY LT+w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x65-v6si14609643pff.196.2018.07.31.08.00.23; Tue, 31 Jul 2018 08:00:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732477AbeGaQkK (ORCPT + 99 others); Tue, 31 Jul 2018 12:40:10 -0400 Received: from out30-130.freemail.mail.aliyun.com ([115.124.30.130]:57640 "EHLO out30-130.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732268AbeGaQkK (ORCPT ); Tue, 31 Jul 2018 12:40:10 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07488;MF=xlpang@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0T5iG5K3_1533049129; Received: from xunleideMacBook-Pro.local(mailfrom:xlpang@linux.alibaba.com fp:SMTPD_---0T5iG5K3_1533049129) by smtp.aliyun-inc.com(127.0.0.1); Tue, 31 Jul 2018 22:58:49 +0800 Reply-To: xlpang@linux.alibaba.com Subject: Re: [PATCH] sched/fair: sync expires_seq in distribute_cfs_runtime() To: Cong Wang Cc: LKML , Ben Segall , Linus Torvalds , Peter Zijlstra , Thomas Gleixner References: <20180728002409.5781-1-xiyou.wangcong@gmail.com> From: Xunlei Pang Message-ID: Date: Tue, 31 Jul 2018 22:58:49 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/31/18 1:55 AM, Cong Wang wrote: > On Sun, Jul 29, 2018 at 10:29 PM Xunlei Pang wrote: >> >> Hi Cong, >> >> On 7/28/18 8:24 AM, Cong Wang wrote: >>> Each time we sync cfs_rq->runtime_expires with cfs_b->runtime_expires, >>> we should sync its ->expires_seq too. However it is missing >>> for distribute_cfs_runtime(), especially the slack timer call path. >> >> I don't think it's a problem, as expires_seq will get synced in >> assign_cfs_rq_runtime(). > > Sure, but there is a small window during which they are not synced. > Why do you want to wait until the next assign_cfs_rq_runtime() when > you already know runtime_expires is synced? > > Also, expire_cfs_rq_runtime() is called before assign_cfs_rq_runtime() > inside __account_cfs_rq_runtime(), which means the check of > cfs_rq->expires_seq is not accurate for unthrottling case if the clock > drift happens soon enough? > expire_cfs_rq_runtime(): if (cfs_rq->expires_seq == cfs_b->expires_seq) { /* extend local deadline, drift is bounded above by 2 ticks */ cfs_rq->runtime_expires += TICK_NSEC; } else { /* global deadline is ahead, expiration has passed */ cfs_rq->runtime_remaining = 0; } So if clock drift happens soon, then expires_seq decides the correct thing we should do: if cfs_b->expires_seq advanced, then clear the stale cfs_rq->runtime_remaining from the slack timer of the past period, then assign_cfs_rq_runtime() will refresh them afterwards, otherwise it is a real clock drift. I am still not getting where the race is?