Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp419191ybt; Fri, 19 Jun 2020 05:10:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7VNEC5bCynmzRsbf9pwFx5RagJugzB31znntKU805aTROrKs5Axh6u1K/Hylu1HrX8lGI X-Received: by 2002:a17:906:6b8a:: with SMTP id l10mr3147217ejr.465.1592568608846; Fri, 19 Jun 2020 05:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592568608; cv=none; d=google.com; s=arc-20160816; b=pnfnTyAaTYDwus+hCJ4LZTebTCpR9o1dKzbpw+IFuh7iIvJPbau2CROX1yKGweClT4 23dklzc1GtdhITRgVhA4xfpI2p7QD6UoTyT1SAyLUThIxLBYs1LjFiyO0brnHmnsJr58 MPWL3UOS0ymqFy421fCmaEdwCc7BAs+OqZEBXsC2s8i/WacC30EQYwgp8fIiO/uOhpKx ehz1YwFY8cTzW1ZEx+ee8lhnDBiCfTdCwiF4Ij5oWFTplkDMSCyZZYk6eza4HUHyMiBT asO6ovpWZyrgoM5RnN1U6ow3Q0pu6vIR5PS9ANJwpatnTvWBj4R85IBXzr9MgToIS95h yDyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MNa77Uka+uPnWc2u/Leq2Ulhe8baLYyiuRmc3agmOt0=; b=03PHkvwgO9c3awoTkvBmozOy2bzd9od/GLdoCR2rcWhcKSh7f+4zE6C8dAXcwLTJtF v/a/5c9cmHA7ceXG+LNLof5zL3+VZBuN/tBz7m3db37WuZJIpbGPadYrPuY7W6IZZSUe tY1+zvx9Xi4NNpjKpHjExQM6gjLdS6MIuIOJSVmUOMQYMkEBTJ0HmxsIM1/YHBYnXpNK qsqZoA3BG7PHzl9Ty5qOVzNGiL+vw6ut5SiZ7drbS5bVt9zfs9KHPprajGsLCjfS6nGb u5oARZMPN5Kwi1jxBUtJCuEjxcWfDVwON/xKcffdSeFwxWOXC1+UTXvIAjIoTjWbcmyQ LtAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oeJ1FTSt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si3630827edt.402.2020.06.19.05.09.46; Fri, 19 Jun 2020 05:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=oeJ1FTSt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731358AbgFSIab (ORCPT + 99 others); Fri, 19 Jun 2020 04:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730651AbgFSIa3 (ORCPT ); Fri, 19 Jun 2020 04:30:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FB63C06174E for ; Fri, 19 Jun 2020 01:30:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=MNa77Uka+uPnWc2u/Leq2Ulhe8baLYyiuRmc3agmOt0=; b=oeJ1FTStEQBysI1B1Hq5UE1IdN 8ElI9XqQz6k9cGSfGCzFJBxRnRuATG34FvbvuUPNasgdmnpg9SyPUCJmSqPSPo95ZKOqbWPrCyhpf WbhoIZeu6QMKfHm299rhCaDGBiMSHW/nW3tXm/yxWUbxJ+ws6roeqSrXM2d6/JLkDVNSSD/rDERMk spsxSU2Ua0f2DmQR4Rvg4PAH9Ocvd3InwpmQ+ioSw+8LrJvm5aUhstLc3Tzu5P6rR8dQ5RRHwSTQq V0K5XQDw06XyLkiN+f6Wmv5b3zI+eJOtoPq3oJ0Z1AB/JLbwmo734BUjZ+judVqJrWqtmOGnTDHGJ JMxg1SUQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jmCPp-00059Q-Hu; Fri, 19 Jun 2020 08:30:25 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D136630604B; Fri, 19 Jun 2020 10:30:23 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id C27DD2038B22F; Fri, 19 Jun 2020 10:30:23 +0200 (CEST) Date: Fri, 19 Jun 2020 10:30:23 +0200 From: Peter Zijlstra To: Axel Rasmussen Cc: Michel Lespinasse , David Howells , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jonathan Adams , David Rientjes , Ying Han Subject: Re: [RFC PATCH v3 1/1] mmap_lock: add tracepoints around mmap_lock acquisition Message-ID: <20200619083023.GS576905@hirez.programming.kicks-ass.net> References: <20200618222225.102337-1-axelrasmussen@google.com> <20200618222225.102337-2-axelrasmussen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618222225.102337-2-axelrasmussen@google.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 18, 2020 at 03:22:25PM -0700, Axel Rasmussen wrote: > diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c > index f11b9bd3431d..6aabea1cbc5d 100644 > --- a/kernel/locking/rwsem.c > +++ b/kernel/locking/rwsem.c > @@ -1495,6 +1495,20 @@ void __sched down_read(struct rw_semaphore *sem) > } > EXPORT_SYMBOL(down_read); > > +/* > + * lock for reading > + */ > +void __sched down_read_contended_hook(struct rw_semaphore *sem, > + void (*pre)(void *), > + void (*post)(void *), void *arg) > +{ > + might_sleep(); > + rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_); > + LOCK_CONTENDED_HOOK(sem, __down_read_trylock, __down_read, pre, post, > + arg); > +} > +EXPORT_SYMBOL(down_read_contended_hook); > + > int __sched down_read_killable(struct rw_semaphore *sem) > { > might_sleep(); > @@ -1509,6 +1523,24 @@ int __sched down_read_killable(struct rw_semaphore *sem) > } > EXPORT_SYMBOL(down_read_killable); > > +int __sched down_read_killable_contended_hook(struct rw_semaphore *sem, > + void (*pre)(void *), > + void (*post)(void *, int), > + void *arg) > +{ > + might_sleep(); > + rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_); > + > + if (LOCK_CONTENDED_HOOK_RETURN(sem, __down_read_trylock, > + __down_read_killable, pre, post, arg)) { > + rwsem_release(&sem->dep_map, _RET_IP_); > + return -EINTR; > + } > + > + return 0; > +} > +EXPORT_SYMBOL(down_read_killable_contended_hook); > + > /* > * trylock for reading -- returns 1 if successful, 0 if contention > */ > @@ -1533,6 +1565,20 @@ void __sched down_write(struct rw_semaphore *sem) > } > EXPORT_SYMBOL(down_write); > > +/* > + * lock for writing > + */ > +void __sched down_write_contended_hook(struct rw_semaphore *sem, > + void (*pre)(void *), > + void (*post)(void *), void *arg) > +{ > + might_sleep(); > + rwsem_acquire(&sem->dep_map, 0, 0, _RET_IP_); > + LOCK_CONTENDED_HOOK(sem, __down_write_trylock, __down_write, pre, post, > + arg); > +} > +EXPORT_SYMBOL(down_write_contended_hook); > + > /* > * lock for writing > */ > @@ -1551,6 +1597,24 @@ int __sched down_write_killable(struct rw_semaphore *sem) > } > EXPORT_SYMBOL(down_write_killable); > > +int __sched down_write_killable_contended_hook(struct rw_semaphore *sem, > + void (*pre)(void *), > + void (*post)(void *, int), > + void *arg) > +{ > + might_sleep(); > + rwsem_acquire_read(&sem->dep_map, 0, 0, _RET_IP_); > + > + if (LOCK_CONTENDED_HOOK_RETURN(sem, __down_write_trylock, > + __down_write_killable, pre, post, arg)) { > + rwsem_release(&sem->dep_map, _RET_IP_); > + return -EINTR; > + } > + > + return 0; > +} > +EXPORT_SYMBOL(down_write_killable_contended_hook); > + > /* > * trylock for writing -- returns 1 if successful, 0 if contention > */ NAK, absolutely not going to happen. This is an atrocious API to expose, worse you're exporting.