Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1488881ybn; Wed, 25 Sep 2019 19:39:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqx4QOQ/e+6iq4V2J7Qs/P3FCZhsInydGF0Dm2UZURSwyeRmvTycE7AyPuTRXaLH6lmDKTkd X-Received: by 2002:a50:cfc7:: with SMTP id i7mr1167776edk.89.1569465587976; Wed, 25 Sep 2019 19:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569465587; cv=none; d=google.com; s=arc-20160816; b=QVTPT+oBD+W+pIJlPPr0P6Co+dJo+eb+Owm2sFiR6JXVkxcUSanHDCW9dvc026l1hg OKtnbjSDgJ920mIM4cbsspHeTDlW/FeiSqNVvshI1QN2BWtOAV0UYoc+019HhEuQJkV8 dF5Get1cLpU9i9S/wufwEAOzW+8B4PiYtYWUa7luaqT3uCUp+Tk8+4XkgAKFrDm0zqGh GAWsJ8DuKofR4QifzVGKtP2VOGIK3LNNxDq27fQr8QFJFylD1EAtyMhEHrIiKDDj+2AM stCZm7ieZyXlvEW9LKnRkOx0ysZxPWJLKcgpVGc7aVd/OI2deWLSAQgCUgAmYIBqYirC qzAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version; bh=zev3GJH2+zVfbHOVossQJqrsrTdexNleqPzrfbyHBR0=; b=Psyx+76v9VpoOuBThcvcHoRyKQuS1WyHyGVBYSlxw+6AviwRC3X6flCF6z6rvcItT3 H84EQkU2macYKvEfwDVqlbUpSAHmuDlR5hc9mSdgeQXwIGIBm6OaQWsp16akinXAXUMu 07aUpXWLq9yPuc+6cUZINr+xrLr9bFy6mRuFNiqoTWMSR1UcPMhslGSKZtcPZlGI/vH2 NzpBUZz33eFJ1cACZ0CBk3+KcTttVvrtgneBCeqcAwChzH449L/84l9wOhS/4ZOLEQRq C9tc5Cy+FtM1StGkmlY+MJj1pCLu6RKkPfz+5d8Pam4RcBQd+5mSERWTc5h373mA352o hvAw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si332931ejz.242.2019.09.25.19.39.24; Wed, 25 Sep 2019 19:39: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; 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 S2440436AbfIWTYB (ORCPT + 99 others); Mon, 23 Sep 2019 15:24:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:54494 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2440392AbfIWTYB (ORCPT ); Mon, 23 Sep 2019 15:24:01 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2F23CAD72; Mon, 23 Sep 2019 19:23:59 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 23 Sep 2019 21:23:57 +0200 From: Roman Penyaev To: Jason Baron Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Davidlohr Bueso , Al Viro , Eric Wong Subject: Re: [PATCH] epoll: simplify ep_poll_safewake() for CONFIG_DEBUG_LOCK_ALLOC In-Reply-To: References: <1567628549-11501-1-git-send-email-jbaron@akamai.com> Message-ID: <1b26e25fcc0e6c54cbdb9e66dade17db@suse.de> X-Sender: rpenyaev@suse.de User-Agent: Roundcube Webmail Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-09-23 17:43, Jason Baron wrote: > On 9/4/19 4:22 PM, Jason Baron wrote: >> Currently, ep_poll_safewake() in the CONFIG_DEBUG_LOCK_ALLOC case uses >> ep_call_nested() in order to pass the correct subclass argument to >> spin_lock_irqsave_nested(). However, ep_call_nested() adds unnecessary >> checks for epoll depth and loops that are already verified when doing >> EPOLL_CTL_ADD. This mirrors a conversion that was done for >> !CONFIG_DEBUG_LOCK_ALLOC in: commit 37b5e5212a44 ("epoll: remove >> ep_call_nested() from ep_eventpoll_poll()") >> >> Signed-off-by: Jason Baron >> Cc: Davidlohr Bueso >> Cc: Roman Penyaev >> Cc: Al Viro >> Cc: Eric Wong >> Cc: Andrew Morton >> --- >> fs/eventpoll.c | 36 +++++++++++++----------------------- >> 1 file changed, 13 insertions(+), 23 deletions(-) >> >> diff --git a/fs/eventpoll.c b/fs/eventpoll.c >> index d7f1f50..a9b2737 100644 >> --- a/fs/eventpoll.c >> +++ b/fs/eventpoll.c >> @@ -551,28 +551,23 @@ static int ep_call_nested(struct nested_calls >> *ncalls, >> */ >> #ifdef CONFIG_DEBUG_LOCK_ALLOC >> >> -static struct nested_calls poll_safewake_ncalls; >> - >> -static int ep_poll_wakeup_proc(void *priv, void *cookie, int >> call_nests) >> -{ >> - unsigned long flags; >> - wait_queue_head_t *wqueue = (wait_queue_head_t *)cookie; >> - >> - spin_lock_irqsave_nested(&wqueue->lock, flags, call_nests + 1); >> - wake_up_locked_poll(wqueue, EPOLLIN); >> - spin_unlock_irqrestore(&wqueue->lock, flags); >> - >> - return 0; >> -} >> +static DEFINE_PER_CPU(int, wakeup_nest); >> >> static void ep_poll_safewake(wait_queue_head_t *wq) >> { >> - int this_cpu = get_cpu(); >> - >> - ep_call_nested(&poll_safewake_ncalls, >> - ep_poll_wakeup_proc, NULL, wq, (void *) (long) this_cpu); >> + unsigned long flags; >> + int subclass; >> >> - put_cpu(); >> + local_irq_save(flags); >> + preempt_disable(); >> + subclass = __this_cpu_read(wakeup_nest); >> + spin_lock_nested(&wq->lock, subclass + 1); >> + __this_cpu_inc(wakeup_nest); >> + wake_up_locked_poll(wq, POLLIN); >> + __this_cpu_dec(wakeup_nest); >> + spin_unlock(&wq->lock); >> + local_irq_restore(flags); >> + preempt_enable(); >> } What if reduce number of lines with something as the following: int this_cpu = get_cpu(); subclass = __this_cpu_inc_return(wakeup_nest); spin_lock_irqsave_nested(&wq->lock, flags, subclass); wake_up_locked_poll(wq, POLLIN); spin_unlock_irqrestore(&wq->lock, flags); __this_cpu_dec(wakeup_nest); put_cpu(); Other than that looks good to me. Reviewed-by: Roman Penyaev -- Roman