Received: by 10.213.65.68 with SMTP id h4csp1637352imn; Thu, 15 Mar 2018 05:38:47 -0700 (PDT) X-Google-Smtp-Source: AG47ELshSeXKRyPj98nB6eRgGrzFBlgaU+82aGtQ652G69obGzcJvorXvIouMNcO917kzfVy1Cm3 X-Received: by 2002:a17:902:8e83:: with SMTP id bg3-v6mr8128635plb.144.1521117527612; Thu, 15 Mar 2018 05:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521117527; cv=none; d=google.com; s=arc-20160816; b=ESfCoWcNdMiybMv8/w2YTAeav2ONH4HCjC7J8D0w57zfdv5V36fWjS6J5R6Vr3m6Vh j7qizUXahysZhFPBuyauNcWPxovd2EUx0ng78UxTr3fu1aaQv5SnS82I7nSyKd5+ctW/ AfKG9ka14o5Ql+oE+58PqMeWwe3SYsGpySdaVTLoAYdQJtGvCnpf7x41IBK+bzNKdF97 9Si+VcJgJBjXXIBiskJ39vdKNfS2BOK1f+M2Z58WQGv+gCZ2NwsmMmQ0+GNwBVZmEIfM Q+gCTShST/cLdDjRoL4EQNTzqmww/3NONva31BkdkI2KXX0EpdrTNFzEXpElm/ZnmwMI whUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :references:subject:cc:to:from:date:user-agent:message-id :dkim-signature:arc-authentication-results; bh=9hBAxx8S0G36XqiI6b9pxsIK/Veb9RIn4Vp7MnHxLwI=; b=umszkSZ8jgSYT1PrRSXLWbYCxz9rNmPmmHW56/VM8r1ERX2VjooAE112baRRUf8RxZ iB7G58y421k5guHd8xORt+uMvhBU1oAHTlDlohP4MwgLIEMMTeWy+Sh0THnxiv3e/v1a IEi4J3Di3VGSyT/RmmIPJCJYFyQUQ5+RL0Xn2OpeKO2fZBDuni7p0FcrehoiMZq5ycAc F54evMPP+psqj7yg5LKxyhUO+ro0ivLY/lbn9QeFE+dvz6qKWNaxLWAdws/CJGDp6Adj 94tbO6hCFFF8jL3VeLr8n/HWJZS0UZ8069CHd93txjC9skILEFigIewo1bDZOXLAlv6h WFhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=KIzdAAaK; 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 y4-v6si3894150plb.568.2018.03.15.05.38.33; Thu, 15 Mar 2018 05:38:47 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=KIzdAAaK; 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 S1752150AbeCOMhH (ORCPT + 99 others); Thu, 15 Mar 2018 08:37:07 -0400 Received: from merlin.infradead.org ([205.233.59.134]:49182 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751869AbeCOMfn (ORCPT ); Thu, 15 Mar 2018 08:35:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-Id:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=9hBAxx8S0G36XqiI6b9pxsIK/Veb9RIn4Vp7MnHxLwI=; b=KIzdAAaK1qmDaoeRdUEmf/dHvY nFYX5/fOfXLjFmWtl+L4PsIN3W1ZWx4OKrodKQlP/IPU4lj41ykL31EK/NNjWfLcvgGRB956sEPeZ e43IA93RAP6jhks+kfTWYJyVMjTnWvsEf3CDvIST/pMHuauT2TSQBSXpAtNfX+/aWroV2mKnCdVO+ pC8A0MHxyj5JEa14Sm53OLsSZTmSdygALpOZ/oFiFVY0ELRtsLHp+lFb0h0l0trWl436T1cmJQXS0 4UOEL9oV70Xi3N/3JRhjSsnICfMPsr1/rc4HVjKwjFG9G5jIz+JzqzUA7dvUy1khXAOPraLjpsHAN fwlYYIfw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1ewS6L-00038Q-Ru; Thu, 15 Mar 2018 12:35:22 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 0ADDD2019C0A2; Thu, 15 Mar 2018 13:35:19 +0100 (CET) Message-Id: <20180315123202.419618431@infradead.org> User-Agent: quilt/0.63-1 Date: Thu, 15 Mar 2018 13:19:04 +0100 From: Peter Zijlstra To: Ingo Molnar , linux-kernel@vger.kernel.org Cc: Dan Williams , David Howells , Daniel Vetter , David Airlie , Stanimir Varbanov , Chris Mason , Anna Schumaker , Joel Becker , James Hogan , Ralf Baechle , Linus Torvalds , George Spelvin , "Peter Zijlstra (Intel)" Subject: [PATCH 02/11] sched/wait,drm: Replace wait_on_atomic_t usage References: <20180315121902.942902000@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-wait_var-2.patch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Convert the wait_on_atomic_t() usage to the new wait_var_event() API. Unlike the wake_up_atomic_t(), wake_up_var() will issue the wakeup even if the variable is not 0. Cc: Daniel Vetter Cc: David Airlie Signed-off-by: Peter Zijlstra (Intel) --- drivers/gpu/drm/drm_dp_aux_dev.c | 13 +++++++------ drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c | 14 ++++---------- 2 files changed, 11 insertions(+), 16 deletions(-) --- a/drivers/gpu/drm/drm_dp_aux_dev.c +++ b/drivers/gpu/drm/drm_dp_aux_dev.c @@ -177,8 +177,9 @@ static ssize_t auxdev_read_iter(struct k res = pos - iocb->ki_pos; iocb->ki_pos = pos; - atomic_dec(&aux_dev->usecount); - wake_up_atomic_t(&aux_dev->usecount); + if (atomic_dec_and_test(&aux_dev->usecount)) + wake_up_var(&aux_dev->usecount); + return res; } @@ -218,8 +219,9 @@ static ssize_t auxdev_write_iter(struct res = pos - iocb->ki_pos; iocb->ki_pos = pos; - atomic_dec(&aux_dev->usecount); - wake_up_atomic_t(&aux_dev->usecount); + if (atomic_dec_and_test(&aux_dev->usecount)) + wake_up_var(&aux_dev->usecount); + return res; } @@ -277,8 +279,7 @@ void drm_dp_aux_unregister_devnode(struc mutex_unlock(&aux_idr_mutex); atomic_dec(&aux_dev->usecount); - wait_on_atomic_t(&aux_dev->usecount, atomic_t_wait, - TASK_UNINTERRUPTIBLE); + wait_var_event(&aux_dev->usecount, !atomic_read(&aux_dev->usecount)); minor = aux_dev->index; if (aux_dev->dev) --- a/drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c +++ b/drivers/gpu/drm/i915/selftests/intel_breadcrumbs.c @@ -271,18 +271,13 @@ struct igt_wakeup { u32 seqno; }; -static int wait_atomic_timeout(atomic_t *p, unsigned int mode) -{ - return schedule_timeout(10 * HZ) ? 0 : -ETIMEDOUT; -} - static bool wait_for_ready(struct igt_wakeup *w) { DEFINE_WAIT(ready); set_bit(IDLE, &w->flags); if (atomic_dec_and_test(w->done)) - wake_up_atomic_t(w->done); + wake_up_var(w->done); if (test_bit(STOP, &w->flags)) goto out; @@ -299,7 +294,7 @@ static bool wait_for_ready(struct igt_wa out: clear_bit(IDLE, &w->flags); if (atomic_dec_and_test(w->set)) - wake_up_atomic_t(w->set); + wake_up_var(w->set); return !test_bit(STOP, &w->flags); } @@ -342,7 +337,7 @@ static void igt_wake_all_sync(atomic_t * atomic_set(ready, 0); wake_up_all(wq); - wait_on_atomic_t(set, atomic_t_wait, TASK_UNINTERRUPTIBLE); + wait_var_event(set, !atomic_read(set)); atomic_set(ready, count); atomic_set(done, count); } @@ -350,7 +345,6 @@ static void igt_wake_all_sync(atomic_t * static int igt_wakeup(void *arg) { I915_RND_STATE(prng); - const int state = TASK_UNINTERRUPTIBLE; struct intel_engine_cs *engine = arg; struct igt_wakeup *waiters; DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); @@ -418,7 +412,7 @@ static int igt_wakeup(void *arg) * that they are ready for the next test. We wait until all * threads are complete and waiting for us (i.e. not a seqno). */ - err = wait_on_atomic_t(&done, wait_atomic_timeout, state); + err = wait_var_event_timeout(&done, !atomic_read(&done), 10 * HZ); if (err) { pr_err("Timed out waiting for %d remaining waiters\n", atomic_read(&done));