Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1025709imj; Thu, 7 Feb 2019 16:13:02 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibce3J0gqY2k517u1wyFVnYkr/WnNiBQn93mPG8P0oblbvlhu1Kw/d9yNzfDFYxu0hjqTKP X-Received: by 2002:a63:9b11:: with SMTP id r17mr17596523pgd.416.1549584782133; Thu, 07 Feb 2019 16:13:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549584782; cv=none; d=google.com; s=arc-20160816; b=KsEhv7Mcb2nKAzOe4aJo+Hr5C5vMcAInOtuVP6BQ3avq3/S9BdTZi62GcFEzhTjRPJ rLt1t9O6vRCUdKQOYgZ9tfc0og7YvMAxEZ5KoJRW7UF7y2GJoK/6rQ2OorFgqI2WQWyw rIhzCpCSUTXsaWMwhyv9KcJhtcUkrxP2Hc+oRy7x6gopJ60eb13RWqBrMVjyX0GTKS6k ZFCY3QX/9jslECgIdhGSViMX/pAoylPCcNxntHp1Buo8mZZW8bnVZc4J7pzAZPeclbQ9 AspYU0EmEsaZ+rmxA2QhCRv0rS2GVFUdTXojJAv4xXxbr4UymC+11Ui0mZmUaQt3laOE oGbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ziH7ipE4YsT+vEbiN9gcgpdJaPcE7R4YBZiJRtwCj98=; b=UA1tAq8KsWZOZ8lKMiBTflwHaW1QNAtP9X4heVc0m3vaDufBHaSyYTgRykQ3JaEr+A BimrFivIDOMdKXGki5KyMSTCiU0tiESjWZbQNfnvZNhPgA34jAkmr5s773wB/132w7qZ tpjIDGgQcCCW93fsizGAtBAeTXpXSm9l/ZOWfwX4r0+TJ3pN7cqN7k3jQ14jl3U/4tUE jEtE/zrX/tiCA5l8WoHPchZ+t1TK9AGBzn1OKIguzST3JU+PPcKRhua1/qaOlCOA1o4I EN4+093a+UTiFv3TTingNFPjRut4fB6x7l5gBN7hV4GvTYIOX4Das2TIZdN6Vb5JjR16 lnMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=fLgRKbn2; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d13si459355pgh.196.2019.02.07.16.12.46; Thu, 07 Feb 2019 16:13:02 -0800 (PST) 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=@joelfernandes.org header.s=google header.b=fLgRKbn2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726943AbfBHAMh (ORCPT + 99 others); Thu, 7 Feb 2019 19:12:37 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:40912 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbfBHAMh (ORCPT ); Thu, 7 Feb 2019 19:12:37 -0500 Received: by mail-qt1-f193.google.com with SMTP id j36so2075696qta.7 for ; Thu, 07 Feb 2019 16:12:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=ziH7ipE4YsT+vEbiN9gcgpdJaPcE7R4YBZiJRtwCj98=; b=fLgRKbn2Q3flTnpQZrvBPXiHD/eZJHY3Katb4B8IbNhwxK8zceFip+dExUYhtMVaZA c+bhiWnLiLhwtQQPxfJsbCqs+dgyRgI852v16raWutiaoNWAotsgu78vcxBvgM+OHyDD 6quzj3VVBYgQXD6MGNn72j4dTio2TmcZqiYPo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=ziH7ipE4YsT+vEbiN9gcgpdJaPcE7R4YBZiJRtwCj98=; b=pKBAd+VQdkaw/j56a6ABR1/jHdc4vQItj2iMtsDyL/CGoYUEVs/x4PUaTiSq3TdpPC SwUWz3olrWKDIDGBoO93Xpu4akVz6/gmncycz76mP7pTh4NlyZDOvj0yFg64Y0MJrPNL KrUEaA1WC/XWVsMOh4hqR0nJ3taJcOXa46xBzmg76ma5ZGIdNCBV0IFpeo5dHPuHtO/M SlX1kfNoegSRj3z3LgKmEFz19oYSYkqbQhxrwIh2drW01AyT4DMksq8zvgFmbD32ck9X ABe5HYPILTemZnUH4kJmmn6QtmFqLCu65Lkb6tagljhUfecJ74CSHAW+7CH7ljA4dbYC Pq4A== X-Gm-Message-State: AHQUAubELXodeyuqGzuCrmxl9QbDLo9zs4GJgMxYPXruAHchC4aOacO4 ghPxqAU0KImr8PWf5nOx/QqMT/5nQro= X-Received: by 2002:ac8:2783:: with SMTP id w3mr14282122qtw.221.1549584756682; Thu, 07 Feb 2019 16:12:36 -0800 (PST) Received: from localhost ([2620:0:1004:1100:cca9:fccc:8667:9bdc]) by smtp.gmail.com with ESMTPSA id g3sm421502qkc.54.2019.02.07.16.12.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 07 Feb 2019 16:12:35 -0800 (PST) Date: Thu, 7 Feb 2019 19:12:35 -0500 From: Joel Fernandes To: Hugo Lefeuvre Cc: Ingo Molnar , Peter Zijlstra , linux-kernel@vger.kernel.org, "Rafael J. Wysocki" Subject: Re: [PATCH v2] sched/wait: use freezable_schedule when possible Message-ID: <20190208001235.GC193818@google.com> References: <20190207200352.GA27859@behemoth.owl.eu.com.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190207200352.GA27859@behemoth.owl.eu.com.local> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 07, 2019 at 09:03:52PM +0100, Hugo Lefeuvre wrote: > Replace schedule(); try_to_freeze() by freezable_schedule(). > > Tasks calling freezable_schedule() set the PF_FREEZER_SKIP flag > before calling schedule(). Unlike tasks calling schedule(); > try_to_freeze() tasks calling freezable_schedule() are not awaken by > try_to_freeze_tasks(). Instead they call try_to_freeze() when they > wake up if the freeze is still underway. > > It is not a problem since sleeping tasks can't do anything which isn't > allowed for a frozen task while sleeping. > > The result is a potential performance gain during freeze, since less > tasks have to be awaken. > > For instance on a bare Debian vm running a 4.19 stable kernel, the > number of tasks skipped in freeze_task() went up from 12 without the > patch to 32 with the patch (out of 448), an increase of > x2.5. > Reviewed-by: Joel Fernandes (Google) > Signed-off-by: Hugo Lefeuvre > --- > Changes in v2: > - Add test results to commit message. > - Split from initial patch set[0] since this patch can go in separately > [0] https://lkml.org/lkml/2019/2/1/19 > > include/linux/wait.h | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/include/linux/wait.h b/include/linux/wait.h > index ed7c122cb31f..5f3efabc36f4 100644 > --- a/include/linux/wait.h > +++ b/include/linux/wait.h > @@ -308,7 +308,7 @@ do { \ > > #define __wait_event_freezable(wq_head, condition) \ > ___wait_event(wq_head, condition, TASK_INTERRUPTIBLE, 0, 0, \ > - schedule(); try_to_freeze()) > + freezable_schedule()) > > /** > * wait_event_freezable - sleep (or freeze) until a condition gets true > @@ -367,7 +367,7 @@ do { \ > #define __wait_event_freezable_timeout(wq_head, condition, timeout) \ > ___wait_event(wq_head, ___wait_cond_timeout(condition), \ > TASK_INTERRUPTIBLE, 0, timeout, \ > - __ret = schedule_timeout(__ret); try_to_freeze()) > + __ret = freezable_schedule_timeout(__ret)) > > /* > * like wait_event_timeout() -- except it uses TASK_INTERRUPTIBLE to avoid > @@ -588,7 +588,7 @@ do { \ > > #define __wait_event_freezable_exclusive(wq, condition) \ > ___wait_event(wq, condition, TASK_INTERRUPTIBLE, 1, 0, \ > - schedule(); try_to_freeze()) > + freezable_schedule()) > > #define wait_event_freezable_exclusive(wq, condition) \ > ({ \ > -- > 2.20.1