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=-5.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 1D7CBC433E1 for ; Wed, 17 Jun 2020 23:46:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D64DD21548 for ; Wed, 17 Jun 2020 23:46:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="HUfgpYwy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D64DD21548 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AD5756B000C; Wed, 17 Jun 2020 19:46:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A864D6B000D; Wed, 17 Jun 2020 19:46:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 926306B000E; Wed, 17 Jun 2020 19:46:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0081.hostedemail.com [216.40.44.81]) by kanga.kvack.org (Postfix) with ESMTP id 779DE6B000C for ; Wed, 17 Jun 2020 19:46:11 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D7AA424386 for ; Wed, 17 Jun 2020 23:46:10 +0000 (UTC) X-FDA: 76940339700.05.rule30_21070c226e0b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id B0A0F1826B6A5 for ; Wed, 17 Jun 2020 23:46:10 +0000 (UTC) X-HE-Tag: rule30_21070c226e0b X-Filterd-Recvd-Size: 3979 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Wed, 17 Jun 2020 23:46:10 +0000 (UTC) Received: from paulmck-ThinkPad-P72.home (50-39-105-78.bvtn.or.frontiernet.net [50.39.105.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 83F23207E8; Wed, 17 Jun 2020 23:46:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592437569; bh=M7bG+rSHSEDHF2Qry9Zk4SV+gGKCbl4sGRVOdFojW+4=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=HUfgpYwyNBOTeYNYb/UuaWuV4M7LYIjs+fIVd5OF+TCaLqEQK6a+xaIbb50JIhdB0 4X7NuWBSpb4wZVP5UmBhN27cOT0A7G0HYtfTZVvGhv+4D/SC7XlLxcI+022GMzRi0c mesUzHw/QEVJ9z3YjRh+D1v2du+ew+W9r2Xz6iWY= Received: by paulmck-ThinkPad-P72.home (Postfix, from userid 1000) id 6B8B03523551; Wed, 17 Jun 2020 16:46:09 -0700 (PDT) Date: Wed, 17 Jun 2020 16:46:09 -0700 From: "Paul E. McKenney" To: "Uladzislau Rezki (Sony)" Cc: LKML , linux-mm@kvack.org, Andrew Morton , "Theodore Y . Ts'o" , Matthew Wilcox , Joel Fernandes , RCU , Oleksiy Avramchenko Subject: Re: [PATCH v2 09/16] rcu/tree: Maintain separate array for vmalloc ptrs Message-ID: <20200617234609.GA10087@paulmck-ThinkPad-P72> Reply-To: paulmck@kernel.org References: <20200525214800.93072-1-urezki@gmail.com> <20200525214800.93072-10-urezki@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200525214800.93072-10-urezki@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Rspamd-Queue-Id: B0A0F1826B6A5 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 Mon, May 25, 2020 at 11:47:53PM +0200, Uladzislau Rezki (Sony) wrote: > To do so, we use an array of kvfree_rcu_bulk_data structures. > It consists of two elements: > - index number 0 corresponds to slab pointers. > - index number 1 corresponds to vmalloc pointers. > > Keeping vmalloc pointers separated from slab pointers makes > it possible to invoke the right freeing API for the right > kind of pointer. > > It also prepares us for future headless support for vmalloc > and SLAB objects. Such objects cannot be queued on a linked > list and are instead directly into an array. > > Signed-off-by: Uladzislau Rezki (Sony) > Signed-off-by: Joel Fernandes (Google) > Reviewed-by: Joel Fernandes (Google) > Co-developed-by: Joel Fernandes (Google) > --- [ . . . ] > + // 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 am taking this as is, but if you have not already done so, could you please look into this for a follow-up patch? Thanx, Paul