Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1004958ybn; Wed, 25 Sep 2019 10:51:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1BedOk5813TqKcQpIrI0sp/XWuFuCS4qCaJckLqtfFVr4baOPOHmDIzzisgYlMC2G8SVl X-Received: by 2002:a05:6402:1251:: with SMTP id l17mr4326461edw.270.1569433914415; Wed, 25 Sep 2019 10:51:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569433914; cv=none; d=google.com; s=arc-20160816; b=etWAOkNP2w69F51XXGBR32ZVAAYo0/vEnswuS6cbHTlH7M4jJmNGfm5FJ09x7vMqxS sWEHD7lGEPY+PU02aaDJ17HW2WfeYTmq4Gh/MFj3Y/wtFaPO1M++/StTPM7RBfSnQEdc WegNr8J34ajUiJjOFeV+60HXbWxa+W4m60RO4PzDkkC5UIUhDnB9UKjJyZEoo0H2N2vf JzRK5mi1v7rRbbBNg3VdyC6nmyPvWbxsJP7i7cA5eJVDQK6huKWTyCobwWXCOPQiGeA+ GuMVuobc/dzVkHBU8eGPM9wRsVl0L6lV7J3yJXs7Nw1dRgy7bhPB2GOSrMaeqvhdFkF6 9aBw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:references:cc:to:from:subject :dkim-signature; bh=qX9gUJnUPb1Fcd+p95CXTaKPJoXRkYXmCntvF2VuC1U=; b=kQIgg3WlqAriGr/KR8tO61DVrmsh0VO8wxAVaEqhGHFOrPnugEK6u4KPtVP4KBhxBE niWhFXlEMSnSgeUriRSX9ejcQbS7i7c+srAIsM6rec8TSh/P6e2Z/kj0UXM4AyP8hOug z4irVCZ5PXwI94UvqRVwfUo4IQdeGMPxi44Ax95bRbH9eKXws8jwgS8UEmCfncocjo9J spWE/iVvs6J7kFIjIDRXjIdbZpkrFjJL4PD9m8boYYK2GJmhPQmZYoaKtq5fPDiZg7YD G+MGxsbrTBrjN0wjiyYDcbyuXUwEuXiNQhJx4xS9v6r2agBLukHysWYRz2XxiohUtXTx sDZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b=YARDN5pc; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12si4191085edk.16.2019.09.25.10.51.29; Wed, 25 Sep 2019 10:51:54 -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=@akamai.com header.s=jan2016.eng header.b=YARDN5pc; 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=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732661AbfIWPoL (ORCPT + 99 others); Mon, 23 Sep 2019 11:44:11 -0400 Received: from mx0b-00190b01.pphosted.com ([67.231.157.127]:14444 "EHLO mx0b-00190b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732362AbfIWPoL (ORCPT ); Mon, 23 Sep 2019 11:44:11 -0400 Received: from pps.filterd (m0050096.ppops.net [127.0.0.1]) by m0050096.ppops.net-00190b01. (8.16.0.42/8.16.0.42) with SMTP id x8NFb82o006988; Mon, 23 Sep 2019 16:43:59 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=subject : from : to : cc : references : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=jan2016.eng; bh=qX9gUJnUPb1Fcd+p95CXTaKPJoXRkYXmCntvF2VuC1U=; b=YARDN5pcyVBafhMU39v9guV9kFLt98byO8ytBI60+09E0lqOkoxfT7kvghI/NnX04W4D 0Ijmpf6SPrf9tQXLN088cHZhxZByMhOVbdayZP5b1EAt+pD+xDSCc3/PwPawgWNbbrn/ 1oyckYorcDUV2W6/CsUgs1Dm2yuv3ODE4WGHNsEmr1Nu4yFODxOP4UhvuxXWMzakKs4j q6BF9+wTQezaQkUlb3qltXDfdH4AhF0PCp8mixSZLzq06ZIw0qJNRNNeeAobkD8xFrXL yDgYiYeGkt9ze03HhT9vv8Ofyt1sSjuMQBciAexEw3cx+2PFs9TeKR8sDjzATniRwyP6 jg== Received: from prod-mail-ppoint6 (prod-mail-ppoint6.akamai.com [184.51.33.61] (may be forged)) by m0050096.ppops.net-00190b01. with ESMTP id 2v5c98h2bs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Sep 2019 16:43:59 +0100 Received: from pps.filterd (prod-mail-ppoint6.akamai.com [127.0.0.1]) by prod-mail-ppoint6.akamai.com (8.16.0.27/8.16.0.27) with SMTP id x8NFZdhT032160; Mon, 23 Sep 2019 11:43:58 -0400 Received: from prod-mail-relay10.akamai.com ([172.27.118.251]) by prod-mail-ppoint6.akamai.com with ESMTP id 2v5f6wamyd-1; Mon, 23 Sep 2019 11:43:58 -0400 Received: from [172.29.170.83] (bos-lpjec.kendall.corp.akamai.com [172.29.170.83]) by prod-mail-relay10.akamai.com (Postfix) with ESMTP id 1EC661FCAA; Mon, 23 Sep 2019 15:43:58 +0000 (GMT) Subject: Re: [PATCH] epoll: simplify ep_poll_safewake() for CONFIG_DEBUG_LOCK_ALLOC From: Jason Baron To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso , Roman Penyaev , Al Viro , Eric Wong References: <1567628549-11501-1-git-send-email-jbaron@akamai.com> Openpgp: preference=signencrypt Autocrypt: addr=jbaron@akamai.com; prefer-encrypt=mutual; keydata= xsFNBFnyIJMBEADamFSO/WCelO/HZTSNbJ1YU9uoEUwmypV2TvyrTrXULcAlH1sXVHS3pNdR I/koZ1V7Ruew5HJC4K9Z5Fuw/RHYWcnQz2X+dSL6rX3BwRZEngjA4r/GDi0EqIdQeQQWCAgT VLWnIenNgmEDCoFQjFny5NMNL+i8SA6hPPRdNjxDowDhbFnkuVUBp1DBqPjHpXMzf3UYsZZx rxNY5YKFNLCpQb1cZNsR2KXZYDKUVALN3jvjPYReWkqRptOSQnvfErikwXRgCTasWtowZ4cu hJFSM5Asr/WN9Wy6oPYObI4yw+KiiWxiAQrfiQVe7fwznStaYxZ2gZmlSPG/Y2/PyoCWYbNZ mJ/7TyED5MTt22R7dqcmrvko0LIpctZqHBrWnLTBtFXZPSne49qGbjzzHywZ0OqZy9nqdUFA ZH+DALipwVFnErjEjFFRiwCWdBNpIgRrHd2bomlyB5ZPiavoHprgsV5ZJNal6fYvvgCik77u 6QgE4MWfhf3i9A8Dtyf8EKQ62AXQt4DQ0BRwhcOW5qEXIcKj33YplyHX2rdOrD8J07graX2Q 2VsRedNiRnOgcTx5Zl3KARHSHEozpHqh7SsthoP2yVo4A3G2DYOwirLcYSCwcrHe9pUEDhWF bxdyyESSm/ysAVjvENsdcreWJqafZTlfdOCE+S5fvC7BGgZu7QARAQABzR9KYXNvbiBCYXJv biA8amJhcm9uQGFrYW1haS5jb20+wsF+BBMBAgAoBQJZ8iCTAhsDBQkJZgGABgsJCAcDAgYV CAIJCgsEFgIDAQIeAQIXgAAKCRC4s7mct4u0M9E0EADBxyL30W9HnVs3x7umqUbl+uBqbBIS GIvRdMDIJXX+EEA6c82ElV2cCOS7dvE3ssG1jRR7g3omW7qEeLdy/iQiJ/qGNdcf0JWHYpmS ThZP3etrl5n7FwLm+51GPqD0046HUdoVshRs10qERDo+qnvMtTdXsfk8uoQ5lyTSvgX4s1H1 pp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CiioThw4OQIw 9Afb+3sB9WR86B7N7sSUTvUArknkNDFefTJJLMzEboRMJBWzpR5OAyLxCWwVSQtPp0IdiIC2 KGF3QXccv/Q9UkI38mWvkilr3EWAOJnPgGCM/521axcyWqXsqNtIxpUAEQEAAcLBZQQYAQIA DwUCWfIgkwIbDAUJCWYBgAAKCRC4s7mct4u0M+AsD/47Q9Gi+HmLyqmaaLBzuI3mmU4vDn+f 50A/U9GSVTU/sAN83i1knpv1lmfG2DgjLXslU+NUnzwFMLI3QsXD3Xx/hmdGQnZi9oNpTMVp tG5hE6EBPsT0BM6NGbghBsymc827LhfYICiahOR/iv2yv6nucKGBM51C3A15P8JgfJcngEnM fCKRuQKWbRDPC9dEK9EBglUYoNPVNL7AWJWKAbVQyCCsJzLBgh9jIfmZ9GClu8Sxi0vu/PpA DSDSJuc9wk+m5mczzzwd4Y6ly9+iyk/CLNtqjT4sRMMV0TCl8ichxlrdt9rqltk22HXRF7ng txomp7T/zRJAqhH/EXWI6CXJPp4wpMUjEUd1B2+s1xKypq//tChF+HfUU4zXUyEXY8nHl6lk hFjW/geTcf6+i6mKaxGY4oxuIjF1s2Ak4J3viSeYfTDBH/fgUzOGI5siBhHWvtVzhQKHfOxg i8t1q09MJY6je8l8DLEIWTHXXDGnk+ndPG3foBucukRqoTv6AOY49zjrt6r++sujjkE4ax8i ClKvS0n+XyZUpHFwvwjSKc+UV1Q22BxyH4jRd1paCrYYurjNG5guGcDDa51jIz69rj6Q/4S9 Pizgg49wQXuci1kcC1YKjV2nqPC4ybeT6z/EuYTGPETKaegxN46vRVoE2RXwlVk+vmadVJlG JeQ7iQ== Message-ID: Date: Mon, 23 Sep 2019 11:43:07 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1567628549-11501-1-git-send-email-jbaron@akamai.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-23_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909230147 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-23_05:2019-09-23,2019-09-23 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 malwarescore=0 impostorscore=0 spamscore=0 clxscore=1015 suspectscore=1 phishscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 mlxscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1909230148 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); > } > > #else > @@ -2370,11 +2365,6 @@ static int __init eventpoll_init(void) > */ > ep_nested_calls_init(&poll_loop_ncalls); > > -#ifdef CONFIG_DEBUG_LOCK_ALLOC > - /* Initialize the structure used to perform safe poll wait head wake ups */ > - ep_nested_calls_init(&poll_safewake_ncalls); > -#endif > - > /* > * We can have many thousands of epitems, so prevent this from > * using an extra cache line on 64-bit (and smaller) CPUs > Hi, Any thoughts on this one? Thanks, -Jason