From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16C21C433E0 for ; Thu, 18 Jun 2020 18:38:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CC21E2083B for ; Thu, 18 Jun 2020 18:38:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="hifGhXI3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC21E2083B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6BB7F8D0018; Thu, 18 Jun 2020 14:38:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6451A6B009D; Thu, 18 Jun 2020 14:38:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 50D098D0018; Thu, 18 Jun 2020 14:38:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id 39AFD6B009C for ; Thu, 18 Jun 2020 14:38:01 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E571D10715F for ; Thu, 18 Jun 2020 18:38:00 +0000 (UTC) X-FDA: 76943191920.06.sort89_3611f3026e12 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id A905A1012BDC9 for ; Thu, 18 Jun 2020 18:38:00 +0000 (UTC) X-HE-Tag: sort89_3611f3026e12 X-Filterd-Recvd-Size: 3016 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 18:38:00 +0000 (UTC) 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=ddwW9UoXI/MN9HL8fzF1g7jZ0jnk2+UjDMVeOqLWnjM=; b=hifGhXI39S1oGvllZSeocYr/9q usv3HGVu7eu7nctGWTyCePuHTwwA/GcMxnB9TSd+iIOwVI6pHHzBfZWAb85vWO9JpoL5ToFsq2y82 eV54oVNGlHHO9pkg/6e2NdQrnY6FR68GeJA6fcxynQkjjxibFkoCKZPjxCJdBDxcmQ4FEr58WutBE ySTcBdUEwVgZeXE3BcBZ3HknKVby29ktak1hpUTQB+91OSW2j9avEKU4x42rWUfpmxQ42MxSA/tC8 kuFKPieWdHRzpj01WEYgSji6CNZoMDhzVbzKnhJL95yVn6ZipUVnzbXgNsntgESDTbpY/EVfrJFLs Kdp1o38A==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlzQ7-0000Wp-E8; Thu, 18 Jun 2020 18:37:51 +0000 Date: Thu, 18 Jun 2020 11:37:51 -0700 From: Matthew Wilcox To: Uladzislau Rezki Cc: "Paul E. McKenney" , LKML , linux-mm@kvack.org, Andrew Morton , "Theodore Y . Ts'o" , Joel Fernandes , RCU , Oleksiy Avramchenko Subject: Re: [PATCH v2 09/16] rcu/tree: Maintain separate array for vmalloc ptrs Message-ID: <20200618183751.GT8681@bombadil.infradead.org> References: <20200525214800.93072-1-urezki@gmail.com> <20200525214800.93072-10-urezki@gmail.com> <20200617234609.GA10087@paulmck-ThinkPad-P72> <20200618172504.GA14613@pc636> <20200618173206.GS2723@paulmck-ThinkPad-P72> <20200618175623.GA14865@pc636> <20200618181541.GS8681@bombadil.infradead.org> <20200618182333.GA15082@pc636> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200618182333.GA15082@pc636> X-Rspamd-Queue-Id: A905A1012BDC9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 18, 2020 at 08:23:33PM +0200, Uladzislau Rezki wrote: > > +void vfree_bulk(size_t count, void **addrs) > > +{ > > + unsigned int i; > > + > > + BUG_ON(in_nmi()); > > + might_sleep_if(!in_interrupt()); > > + > > + for (i = 0; i < count; i++) { > > + void *addr = addrs[i]; > > + kmemleak_free(addr); > > + if (addr) > > + __vfree(addr); > > + } > > +} > > +EXPORT_SYMBOL(vfree_bulk); > > + > > > Can we just do addrs[i] all over the loop? > > Also, we can just call vfree() instead that has all checking we > need: NMI, kmemleak, might_sleep. Of course we _can_. But would we want to? This way, we only do these checks once instead of once per pointer, which is rather the point of batching. I might actually go further and hoist the in_interrupt() check into this function ... I suspect the RCU code always runs in_interrupt() and so we always call vfree_deferred().