Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5400323imm; Tue, 31 Jul 2018 10:15:06 -0700 (PDT) X-Google-Smtp-Source: AAOMgpft7xrUw0HVeVfTrmw8tQCnWjrtppRmKdLlgPqiOtkieBLqe56xaFf2ifDQatDAdadAcptK X-Received: by 2002:a65:6203:: with SMTP id d3-v6mr21253114pgv.420.1533057306643; Tue, 31 Jul 2018 10:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533057306; cv=none; d=google.com; s=arc-20160816; b=NjpgzIjSdIzXLFqEiJXgIek7URST9hMz4i1X7JIoQ63R6KGh3G6HHZZhTpAPU4zPH4 6z4Rz+GX0ZdN/phoqoOG53I7y+KmhzPiFwevgJe4FjYm/QkRcQU2okb5VwTRu3bcXZ3U VEr14vp/1Tz4aw0uSXP2KOtuqaM/buF534Z7RRfo16jvijMnbg42wihDclEUHibkA6jo 7X5Qc1e4XFKhFluEYuv0XTbFDMbkscpgGKk/ZY+LB7chba4Tv8KW4b7VVSapEXRM1qCM En1VCeHVrolXnH6lbTQLgKeldHYI6pdye/0oa7hqrz720rySYXtxXEQDWDEgCVm/eySK GG8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=gdwXNdekDSnl/NO1/p7grdZi5izDDgEPpxy8npla8uo=; b=W6Ul5jupOKEvjuL0XrjrzPPIjYvbWK874IpGuvUDiE64sKN8yh9BC7C+jBebvtTtTP 0QeOkLV5A9aiTK/l/RBEcYvioVP2YIqGHLQDh+eIZo0c+uX/3u76CZO8hELJ4mJ2ErVc MCyEvkMbC45jLC1DahhGMXmNzFRxVM4LoVlfSU3PfHmgYQN4rLw0zgWS9uWRb1HNp/Mi ctd9UieEjtf10c/gfBz/waeIA2ceKMP4I0VqWoBj0Eb54uX2C2UcyrEoJUsGVuDYg2a0 PINdtmLgYuco4AFCIWD+m9w4Klj1p9LprjGLE1UaSAsy8WPfUZb+YdZBhhasr704nxJ0 +4cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ePcBT6Ww; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5-v6si13627054pga.227.2018.07.31.10.14.51; Tue, 31 Jul 2018 10:15:06 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=ePcBT6Ww; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729644AbeGaSzQ (ORCPT + 99 others); Tue, 31 Jul 2018 14:55:16 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40392 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727135AbeGaSzP (ORCPT ); Tue, 31 Jul 2018 14:55:15 -0400 Received: by mail-pf1-f195.google.com with SMTP id e13-v6so6423176pff.7 for ; Tue, 31 Jul 2018 10:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=gdwXNdekDSnl/NO1/p7grdZi5izDDgEPpxy8npla8uo=; b=ePcBT6WwpEIrg13QBl1RG0QwwSpryN131KukCK8ix+nJEHYGSNlJ3oqWiIEVGG+mkN Rb/81as6geWRtq/QRpXy6uj/mk//csuJsXH+hWJGWulJ7X7WLOPHXO4Yyij9U78C5wwT l7qqgJ3Y6CPvcigS/clDYs9njmrk7GE/57sKQzgmpRzpCsuCFDvlgswucgB3gzJgkj/4 sy/KHdvJB6c1CCsbDrkB0g9JeEUcHANZSpfma5ktThvO9wn4QVu6DUx9z4tQCy3PXei1 VdOtjbYJ3rgS0TsXq9WrL0UW5UOaAVv4Aox4NQwMbuHNxJPNpBPcjvxppoPP24qMINMF OYbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=gdwXNdekDSnl/NO1/p7grdZi5izDDgEPpxy8npla8uo=; b=k9Ad80/rhf6MFODydypl6ekXYIWd3sdGLDKPRmrrlaByhl13DXNKnwdAhjUJM9WiQh vAA9c7mxgN5VlT/o2CigM3EcUaj+CT/1YorUpGI7Ej0VCIdW515Rb1969iP+XRzC0Zcd FtSJyamXs7LWZ179MsbjJCKkpuayIRS4+9rvHQa3ErQ7YK/VaFkboxFZR3ExekWf6d81 XfH+CtptjwxhTFMNngGvJ4yJRNPAywTZ7/pB67Be/lxGhRS+ATakfEqvcDPsXu0vRYW9 MyXlmmaR99/CulU5QDzmPm5F/QBFr/QQXGAIxlOitgpU7GfzrR+VjzQaUAVUBsCjbhj2 kEEQ== X-Gm-Message-State: AOUpUlF9F3j/6w7UWgvb0+95wlEUanuVXF3h+gWkrJWdCnNUN1BSN95y 3SJ60HxPkqOvYbiQpK4rKslcGA== X-Received: by 2002:a63:4f1a:: with SMTP id d26-v6mr21758578pgb.121.1533057239540; Tue, 31 Jul 2018 10:13:59 -0700 (PDT) Received: from bsegall-linux.svl.corp.google.com.localhost ([2620:15c:2cb:201:549c:c572:5008:d36f]) by smtp.gmail.com with ESMTPSA id s3-v6sm42726399pfg.2.2018.07.31.10.13.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Jul 2018 10:13:58 -0700 (PDT) From: bsegall@google.com To: Xunlei Pang Cc: Cong Wang , LKML , Ben Segall , Linus Torvalds , Peter Zijlstra , Thomas Gleixner Subject: Re: [PATCH] sched/fair: sync expires_seq in distribute_cfs_runtime() References: <20180728002409.5781-1-xiyou.wangcong@gmail.com> Date: Tue, 31 Jul 2018 10:13:56 -0700 In-Reply-To: (Xunlei Pang's message of "Tue, 31 Jul 2018 22:58:49 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xunlei Pang writes: > 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? Nothing /important/ goes wrong because distribute_cfs_runtime only fills runtime_remaining up to 1, not a real amount.