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=-9.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham 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 ECDACC83004 for ; Tue, 28 Apr 2020 20:59:44 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AE335214D8 for ; Tue, 28 Apr 2020 20:59:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mTgjdo+b" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AE335214D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 458458E000C; Tue, 28 Apr 2020 16:59:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 409998E0007; Tue, 28 Apr 2020 16:59:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A9FF8E000C; Tue, 28 Apr 2020 16:59:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id EE6CD8E0007 for ; Tue, 28 Apr 2020 16:59:39 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 71F21824805A for ; Tue, 28 Apr 2020 20:59:39 +0000 (UTC) X-FDA: 76758480078.19.rice60_543d0a681a552 X-HE-Tag: rice60_543d0a681a552 X-Filterd-Recvd-Size: 5181 Received: from mail-lj1-f194.google.com (mail-lj1-f194.google.com [209.85.208.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 28 Apr 2020 20:59:38 +0000 (UTC) Received: by mail-lj1-f194.google.com with SMTP id h4so187067ljg.12 for ; Tue, 28 Apr 2020 13:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/hjFgrHN/AobfDhCW7uHxtGVQp6m3WKcxFSvew6M5pw=; b=mTgjdo+bMst6VnOjdPMHNcx3tuDQ+BDhhX1LfQSV21Z7Uad2qAHdhz6tArXTjHtGWl ryL105FvQsaXCwDc/qECPQ3udl9XQdUVbLE0LAdDz63i47h/7cb7vjI+6eqoIUP0xKsr g5zCswt3KHkAUxPHoA63BYFFGiLwPCNe3NeSZ0/96qaiby/d5cHjc1x6xI+B4aFyLBRx RofJAnQaSKp63kKtqXQ8yj2WYWRRnTdUpWISvo4OIJNJRF8RMuhGfOhhr+D1Nd1Vbgq5 gCRPyRachrNlHGaNEzoS7iOonxh8Ti62fbG8mG+5pWVItXTa0pw/kOk8udN/D99y03Ju 9JVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/hjFgrHN/AobfDhCW7uHxtGVQp6m3WKcxFSvew6M5pw=; b=MV1919CTsQ3/j0DJFI1cwwnAeGQ9mp2bEdO/zMkvpyorsarNFCYP/z90YysPOPFxy+ +X8D3O4bCYsCZCuEYkSiza69ZK4LkgGIZkZgdYP40YUPGzTWF1GxZfdWY7W4/LCLgT6v 3prM7M8WD4DjI2ZIlogEiP0zjr5I1l+4k/6qiFz2+90aOiYWjrrT3CM9YcNVOT/P0hDg 5s/7iYN/vr6z7ZnjR82O3lgqtnijZFn4FrVk4H4JZST2XkHxZdETBBvJ/PAAq0Dp63uf G5n3/IwUdlSL/k4nrqDQ8ox5X+jW9fumMl8wG80GfhNzNZi8ZjLNxGliVkqnylNn94JX zK+Q== X-Gm-Message-State: AGi0PuZeNPQH7R8iyYw2lKOUnys3NdCKq2/erYs72jgxXz7wICypweGI wKIez/v9Yv0fpXJIx2F5l+g= X-Google-Smtp-Source: APiQypLbRFLIsVOfuz0lNkpuDjqlP3snMnoaGJKNyj3Wqv3N49M2dESfMr2LkQ60hBGlniDH8cEjaA== X-Received: by 2002:a2e:9b0f:: with SMTP id u15mr18548017lji.272.1588107577075; Tue, 28 Apr 2020 13:59:37 -0700 (PDT) Received: from pc638.lan (h5ef52e31.seluork.dyn.perspektivbredband.net. [94.245.46.49]) by smtp.gmail.com with ESMTPSA id z21sm295483ljh.42.2020.04.28.13.59.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Apr 2020 13:59:36 -0700 (PDT) From: "Uladzislau Rezki (Sony)" To: LKML , linux-mm@kvack.org Cc: Andrew Morton , "Paul E . McKenney" , "Theodore Y . Ts'o" , Matthew Wilcox , Joel Fernandes , RCU , Uladzislau Rezki , Oleksiy Avramchenko Subject: [PATCH 07/24] rcu/tree: move locking/unlocking to separate functions Date: Tue, 28 Apr 2020 22:58:46 +0200 Message-Id: <20200428205903.61704-8-urezki@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200428205903.61704-1-urezki@gmail.com> References: <20200428205903.61704-1-urezki@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Introduce two helpers to lock and unlock an access to the per-cpu "kfree_rcu_cpu" structure. The reason is to make kfree_call_rcu() function to be more readable. Signed-off-by: Uladzislau Rezki (Sony) --- kernel/rcu/tree.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index eebd7f627794..bc6c2bc8fa32 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -2925,6 +2925,27 @@ debug_rcu_bhead_unqueue(struct kfree_rcu_bulk_data= *bhead) #endif } =20 +static inline struct kfree_rcu_cpu * +krc_this_cpu_lock(unsigned long *flags) +{ + struct kfree_rcu_cpu *krcp; + + local_irq_save(*flags); // For safely calling this_cpu_ptr(). + krcp =3D this_cpu_ptr(&krc); + if (likely(krcp->initialized)) + raw_spin_lock(&krcp->lock); + + return krcp; +} + +static inline void +krc_this_cpu_unlock(struct kfree_rcu_cpu *krcp, unsigned long flags) +{ + if (likely(krcp->initialized)) + raw_spin_unlock(&krcp->lock); + local_irq_restore(flags); +} + /* * This function is invoked in workqueue context after a grace period. * It frees all the objects queued on ->bhead_free or ->head_free. @@ -3150,11 +3171,7 @@ void kfree_call_rcu(struct rcu_head *head, rcu_cal= lback_t func) struct kfree_rcu_cpu *krcp; void *ptr; =20 - local_irq_save(flags); /* For safely calling this_cpu_ptr(). */ - krcp =3D this_cpu_ptr(&krc); - if (krcp->initialized) - raw_spin_lock(&krcp->lock); - + krcp =3D krc_this_cpu_lock(&flags); ptr =3D (void *)head - (unsigned long)func; =20 /* Queue the object but don't yet schedule the batch. */ @@ -3185,9 +3202,7 @@ void kfree_call_rcu(struct rcu_head *head, rcu_call= back_t func) } =20 unlock_return: - if (krcp->initialized) - raw_spin_unlock(&krcp->lock); - local_irq_restore(flags); + krc_this_cpu_unlock(krcp, flags); } EXPORT_SYMBOL_GPL(kfree_call_rcu); =20 --=20 2.20.1