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 60EF8C433E1 for ; Thu, 18 Jun 2020 00:52:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1D79420897 for ; Thu, 18 Jun 2020 00:52:36 +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="idD2mC8F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D79420897 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 B0B036B0006; Wed, 17 Jun 2020 20:52:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A94696B0007; Wed, 17 Jun 2020 20:52:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 98D4C6B000C; Wed, 17 Jun 2020 20:52:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id 7DF296B0006 for ; Wed, 17 Jun 2020 20:52:35 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 0D82E181AC9CB for ; Thu, 18 Jun 2020 00:52:35 +0000 (UTC) X-FDA: 76940507070.29.bell12_291076626e0c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id DCBE018086E39 for ; Thu, 18 Jun 2020 00:52:34 +0000 (UTC) X-HE-Tag: bell12_291076626e0c X-Filterd-Recvd-Size: 3861 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 18 Jun 2020 00:52:30 +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=wnZd+othysjnKDvkqRAupou7YHZYy91X+uiucxvLQzg=; b=idD2mC8FmOi79TIHBN/2QGTXQN 58eJlL9b8Pt7orugy3GXFfZ0Y1z9ctqX84GeV6mS8Bu3N+JxLsuO/6BO9yVyPogsKU0mY27n3ngUM nSrxTf0GDjrS1RFsH9kN8kfYLMia00z9NAq9Y+PyH5d+4cKU0DWYjoXadDBvrMtgbjY+2uakqrrOT cDjZ1dE9++v66981aYKhdondTpA3cea311tr3nr2vshADsxubI5gQCRd5NSURC8ELrYxYjL/QQsih jJ1X0vo6j80+OGG2nBV0rz/vcOwJKkAFa2MKrhxyqbzRQNuRTgZvWHTyDLnT6XCmpvhiiKWYfCcUl U9cxNT4w==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jlims-0003ww-V7; Thu, 18 Jun 2020 00:52:14 +0000 Date: Wed, 17 Jun 2020 17:52:14 -0700 From: Matthew Wilcox To: "Paul E. McKenney" Cc: "Uladzislau Rezki (Sony)" , 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: <20200618005214.GN8681@bombadil.infradead.org> References: <20200525214800.93072-1-urezki@gmail.com> <20200525214800.93072-10-urezki@gmail.com> <20200617234609.GA10087@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200617234609.GA10087@paulmck-ThinkPad-P72> X-Rspamd-Queue-Id: DCBE018086E39 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 Wed, Jun 17, 2020 at 04:46:09PM -0700, Paul E. McKenney wrote: > > + // Handle two first channels. > > + for (i = 0; i < FREE_N_CHANNELS; i++) { > > + for (; bkvhead[i]; bkvhead[i] = bnext) { > > + bnext = bkvhead[i]->next; > > + debug_rcu_bhead_unqueue(bkvhead[i]); > > + > > + rcu_lock_acquire(&rcu_callback_map); > > + if (i == 0) { // kmalloc() / kfree(). > > + trace_rcu_invoke_kfree_bulk_callback( > > + rcu_state.name, bkvhead[i]->nr_records, > > + bkvhead[i]->records); > > + > > + kfree_bulk(bkvhead[i]->nr_records, > > + bkvhead[i]->records); > > + } else { // vmalloc() / vfree(). > > + for (j = 0; j < bkvhead[i]->nr_records; j++) { > > + trace_rcu_invoke_kfree_callback( > > + rcu_state.name, > > + bkvhead[i]->records[j], 0); > > + > > + vfree(bkvhead[i]->records[j]); > > + } > > + } > > + rcu_lock_release(&rcu_callback_map); > > Not an emergency, but did you look into replacing this "if" statement > with an array of pointers to functions implementing the legs of the > "if" statement? If nothing else, this would greatly reduced indentation. I don't think that replacing direct function calls with indirect function calls is a great suggestion with the current state of play around branch prediction. I'd suggest: rcu_lock_acquire(&rcu_callback_map); trace_rcu_invoke_kfree_bulk_callback(rcu_state.name, bkvhead[i]->nr_records, bkvhead[i]->records); if (i == 0) { kfree_bulk(bkvhead[i]->nr_records, bkvhead[i]->records); } else { for (j = 0; j < bkvhead[i]->nr_records; j++) { vfree(bkvhead[i]->records[j]); } } rcu_lock_release(&rcu_callback_map); But I'd also suggest a vfree_bulk be added. There are a few things which would be better done in bulk as part of the vfree process (we batch them up already, but i'm sure we could do better).