Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2089944rwl; Sat, 8 Apr 2023 07:36:04 -0700 (PDT) X-Google-Smtp-Source: AKy350aIsoqeHvsmdF4grsvRKcl6PExWe5YpUXQsP6+hbO/fkNI2ucbXcNlGlsK1uLjJDOli2v7R X-Received: by 2002:a05:6a20:2a22:b0:d9:b0b5:fdaf with SMTP id e34-20020a056a202a2200b000d9b0b5fdafmr5543969pzh.48.1680964564112; Sat, 08 Apr 2023 07:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680964564; cv=none; d=google.com; s=arc-20160816; b=s6HJYYIGj9ktBEXP2M0m2iUDa7vo37dv2TLhFY5D9aPxHXz91fRmQxwVjGmGwZI46/ R360hgxzF7JdSA4ecEsGZB8RjTkEKSPXzPc2LIi+el1FKlbl3i1h+WmrfberDMfbPjly oxKj+wyayVo1SdFJ9VK+CPJN9UgTvG1oTWqBsDo99oH31VSOq3O12cCCnwOburbWNcpC JDs2ouWAwlwZYBqpsOpwt4xu6BmD19jDhw8ntb65tGv226egs0sXO74xIzMy4Zbjctt6 3yeKegbE2o98oLGv32bGxl0xusmsEkJRfm1qtdFTAC8pHeLQfcFykWC19hQRKxPVXfjt DVGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=LkT8RKiCSEPjKstkVq433AGNUL/BdARLZrc/3DFf8X8=; b=zHC3AgSRlKZ7pXJbwBiJOfeTuY6PFMpA2nKP3vrzKsqXvKlvTsmPBQEBHmzQ4eDdpZ OtoWmZlKnnEIZzjsop8JBVbPo1F/IbE63aRS251ljIyVt9Su9eXYmUPPbUgmnxKE/Vew ObcIduW6eJpwoAhT+t9wRQT4ME9hdO5g9Gl7ivAbKVkvQu/H9P3QlLkExuMd+JQwCjZR x6NQvLwQWIZudm1jVWNiwksHw3QKPBE1RJMtbZmGSMzw2+HGqhIvxDsIRYMTrNcJidpY P7gfieXGXMUCEbK/JeJZ+ngql6J242hAx8KJGT7GJ/n/YGrodBldPm7pgzEOJ+lA1VaH Zrcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="a/rpi5K+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h129-20020a625387000000b005cd3a233e3asi6317617pfb.346.2023.04.08.07.35.45; Sat, 08 Apr 2023 07:36:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="a/rpi5K+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbjDHOYz (ORCPT + 99 others); Sat, 8 Apr 2023 10:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229756AbjDHOYx (ORCPT ); Sat, 8 Apr 2023 10:24:53 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2A4BC640; Sat, 8 Apr 2023 07:24:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680963891; x=1712499891; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ReZriI51GMtfmI0Pc8bW8jknlkpzYTRVOz7nIwwjg4M=; b=a/rpi5K+JiWEX7VSZd8sleEXNVdgd2Kp9OuXmc0yzi/DwiCYviYA5MtF P90BYhQWX1KdAPojBpaOY8bsEt7/LQIieFEZKof5c80dQk4B6H70wNBYO kz8hbr5sZciSf5imkatH5sHzTMOVNwNpsKH7nbAZdlzb8D2Q+ORKrYZrr xhLpod+6bMftfzNOJMu/WxWfiyIiQfPmq/PCxKJBs255qKWnEqg/NDuv4 Z+cRTCJqhDCWmho6yK5IhPS66g+yimYPlEwvr9dtqSTQg1L18gIyBxaj+ RlIcbS1PvRIEIR6z3HEAEPtPBd2e7HlS30tb3tNaTlvABXMHDVln1Pa+Q A==; X-IronPort-AV: E=McAfee;i="6600,9927,10674"; a="343147993" X-IronPort-AV: E=Sophos;i="5.98,329,1673942400"; d="scan'208";a="343147993" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2023 07:24:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10674"; a="831461615" X-IronPort-AV: E=Sophos;i="5.98,329,1673942400"; d="scan'208";a="831461615" Received: from ubuntu.bj.intel.com ([10.238.155.108]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2023 07:24:48 -0700 From: Zqiang To: urezki@gmail.com, paulmck@kernel.org, frederic@kernel.org, joel@joelfernandes.org, qiang1.zhang@intel.com Cc: qiang.zhang1211@gmail.com, rcu@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] rcu/kvfree: Make page cache growing happen on the correct krcp Date: Sat, 8 Apr 2023 22:25:30 +0800 Message-Id: <20230408142530.800612-1-qiang1.zhang@intel.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When invoke add_ptr_to_bulk_krc_lock() to queue ptr, will invoke krc_this_cpu_lock() return current CPU's krcp structure and get a bnode object from the krcp structure's ->bulk_head, if return is empty or the returned bnode object's nr_records is KVFREE_BULK_MAX_ENTR, when the can_alloc is set, will unlock current CPU's krcp->lock and allocate bnode, after that, will invoke krc_this_cpu_lock() again to return current CPU's krcp structure, if the CPU migration occurs, the krcp obtained at this time will not be consistent with the previous one, this causes the bnode will be added to the wrong krcp structure's ->bulk_head or trigger fill page work on wrong krcp. This commit therefore re-hold krcp->lock after allocated page instead of re-call krc_this_cpu_lock() to ensure the consistency of krcp. Signed-off-by: Zqiang --- kernel/rcu/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index 9d9d3772cc45..c9076fa0a954 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3303,7 +3303,7 @@ add_ptr_to_bulk_krc_lock(struct kfree_rcu_cpu **krcp, // scenarios. bnode = (struct kvfree_rcu_bulk_data *) __get_free_page(GFP_KERNEL | __GFP_NORETRY | __GFP_NOMEMALLOC | __GFP_NOWARN); - *krcp = krc_this_cpu_lock(flags); + raw_spin_lock_irqsave(&(*krcp)->lock, *flags); } if (!bnode) -- 2.32.0