Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp862975pxb; Thu, 15 Apr 2021 08:17:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNlxc6Yfp7w20PPvCH6xsmMXmVLMNKYOVy5+AZ9iX1/1GKzPBx7LNLdvbwmo0eId0mXWmJ X-Received: by 2002:a63:3c9:: with SMTP id 192mr3956613pgd.423.1618499766491; Thu, 15 Apr 2021 08:16:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1618499766; cv=pass; d=google.com; s=arc-20160816; b=0MJQQJ+AbgTchOsCeN426LS1Q0SJ990c7X1VkO+prMgKMWoY+QMOsRP2rAr0+vOUl0 4Q0Hj838pHKhMTuglHIfgLheOGC+8LKu+rWiV9uqgWk8cKyH7Ut1LPIlHgtZbqefxaaZ y3S6tGb40aujrhMiDQk4Mm1oTMFl/NrYihO2HmhGTjI5jCsdgIbvws6zSRgpaMFWqw+g KaOwNuZ+PAp5HfVOgz2+pe/duVs75xHY8HpJYZuQGlUkH3vVuoDFHFYwoHVepm4JeV3i 2yDR4rjGvB/Vw3UYIWUWx9ra1uyfXBm7gb7AA/DGtNSIa6GlKb2vUKxpUnBAOEnlzmtQ zZAA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-language:user-agent:date:message-id:cc:to:subject:from :dkim-signature; bh=vnruNx+bRqjz5vSKyTyZASmKmVflkk2FEjx1Iqhwmqg=; b=UMcJJ2CZWoT8yc4FC8zL2igmV11HnPC8WhYD8Q484llwMvEplfQeQKQhyaj/DoGGYH 2tjRcLKXbbVSozSl1WZhOCgiqgtd76EUJsqEWlGQRY6fsAHQeOM7fSlXtHZh6SVrcGBp UhxK2WezwmuRp9ZJOUmx/zdq5RF+YQnn1i/ZJt7+d34YtFH8bvJbXtEBQHYmHiv8yH/U 4rAOUSFJMzR4g4mF/oPrkN5RaI2hcdjO0kGRscZy5YSuGAOKYgTBhA0MhfS2qacQVm/X eiDcKEWyTQjUrVzGnkO49zWFTDzvdntgMiPLApKp65wMqjBDP2VdB23kRMsllxkTIiMY XpgQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@windriversystems.onmicrosoft.com header.s=selector2-windriversystems-onmicrosoft-com header.b=e2WXTfel; arc=pass (i=1 spf=pass spfdomain=windriver.com dkim=pass dkdomain=windriver.com dmarc=pass fromdomain=windriver.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si3495239pgj.137.2021.04.15.08.15.53; Thu, 15 Apr 2021 08:16:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@windriversystems.onmicrosoft.com header.s=selector2-windriversystems-onmicrosoft-com header.b=e2WXTfel; arc=pass (i=1 spf=pass spfdomain=windriver.com dkim=pass dkdomain=windriver.com dmarc=pass fromdomain=windriver.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236959AbhDOPPV (ORCPT + 99 others); Thu, 15 Apr 2021 11:15:21 -0400 Received: from mail-mw2nam10on2071.outbound.protection.outlook.com ([40.107.94.71]:52625 "EHLO NAM10-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234638AbhDOPEh (ORCPT ); Thu, 15 Apr 2021 11:04:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EIu0HEKXrckRjar46Sx5dd7LpaklfKiHAVb3TavqhUrQF/EaSDeiWs2MppzvfpITXMtJ1BTxUsts1KYtSQtsxpjE4sn4jQdHRdffav1B/j08OtoldmN1ftjVzyDiFqQhPbrN5FqxyDWRwaBhKtSnHUjRdPa1NZoTz1llmJPKlOmwuiQV5sshI97N45zj9DjmrCZhBaG5+pE/nmfswXmPNAcWHDsAbFUUb4CTZcIeBCiPU7G97n+/bgoNKRki529NxO41CkEINyTNXgJnfbu9+utKzx83KYhqmmXFe5GDtQN0Pj0YOwjicrLiloA13w0LfXSh7GamxPlU1uXsr73BJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vnruNx+bRqjz5vSKyTyZASmKmVflkk2FEjx1Iqhwmqg=; b=X+2Y80esXdJwkLhbfVxbybhvMflNsx8xg7HiJm6XkQY/DHXr4GT61OS9xx4tQ627MqOXqFUw5QAMxVCTRr7+7uJcEaf2WJHwrcuEek6pIovpxr+xkJ7zjOuMTihLLV3EcnbamFbnSr9Lpk/zpjLsTiBSFcDXcP989clVwOHzS5z22Nhqx3sRzpA3I49PNVS0rDomWXc2XVPkhOwGvrRcbwopzB4bYkllkjZOPlEW40mn3f2jwB4eeknIhtHMZbxIjSEFsFIDiH+Vsm0vzTzmHKHbtI2Utu6h9dpZ7tqOwOXIgtmex6oqZfoXEX5vN3SMvcyOL6ufvdnK1T9+uHNUCw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriversystems.onmicrosoft.com; s=selector2-windriversystems-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=vnruNx+bRqjz5vSKyTyZASmKmVflkk2FEjx1Iqhwmqg=; b=e2WXTfellpG4BHnh/w70UDMCzJZ/WuPX7Gg+oi2yn91gWwg4OTWtZkzXFrkoFlgCFvDh8WV5NoF5gVyy8YKLulgpCtvlFMvjm+tiptxxiBCk98Q11mKkYb8sk8QjnE1IQ1hZ4VT9Ympss/f7h+0lzggRrf/sFttmcypvOn/uWX8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=windriver.com; Received: from BY5PR11MB4241.namprd11.prod.outlook.com (2603:10b6:a03:1ca::13) by BYAPR11MB2597.namprd11.prod.outlook.com (2603:10b6:a02:c0::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3999.32; Thu, 15 Apr 2021 15:04:13 +0000 Received: from BY5PR11MB4241.namprd11.prod.outlook.com ([fe80::551b:e310:2ae4:3011]) by BY5PR11MB4241.namprd11.prod.outlook.com ([fe80::551b:e310:2ae4:3011%6]) with mapi id 15.20.4042.018; Thu, 15 Apr 2021 15:04:13 +0000 From: "Xu, Yanfei" Subject: [Qestion] Is preempt_disable/enable needed in non-preemption code path To: paulmck@kernel.org Cc: rcu@vger.kernel.org, LKML Message-ID: Date: Thu, 15 Apr 2021 23:04:05 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [60.247.85.82] X-ClientProxiedBy: SJ0PR05CA0072.namprd05.prod.outlook.com (2603:10b6:a03:332::17) To BY5PR11MB4241.namprd11.prod.outlook.com (2603:10b6:a03:1ca::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from [128.224.162.160] (60.247.85.82) by SJ0PR05CA0072.namprd05.prod.outlook.com (2603:10b6:a03:332::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.6 via Frontend Transport; Thu, 15 Apr 2021 15:04:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: efb53d31-598f-4e90-4cae-08d9001fbab1 X-MS-TrafficTypeDiagnostic: BYAPR11MB2597: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ksuwXmNhjEEgh6SqqltQv1jo92ZOE+GJ7vwj9l+ysfxyRqRC9/qLlSb1Sc4KCG+o4XmFRbak7MTGaHxeAmV5ErmpgcpAKiXtoCKKk9zjQSGkDdbKhwvSWAnqxQyWmrumdz128qcbiTz0Uqq7nr5NRGdEfPsEduYzrThG0YxT2qkyT/6xnSE8s5PiGyetw7lmHW0Rt3U8tbcM80/esYshhVLPY5RHuiLq4Ug4sqBqHiGN3bpaJ5PBLeA283Vbhqvj7Bu75oUBKJK8ymjrAS0R81HnK4BNwqz1XhAi59PFZJwz5QTC3HktwUZw05MTcA+fdtB6ZYdSEgCZ5oqb+r0opqDiLqdejvUHufekXfPkaQ6G7Rd8zQVgWbVVJMa2OomW6tZ7KnXKTKgzHJgqtoLy7v5S0TFzkoveOPRp8IclpSoAt6bKMFzV9VfnKkoqjzihCQo5VnoVF1KbMTiC2UOQE2ovbsRjrzigiLLl7HBLfGcRDlzwI+P+ds6PU64RBZ+odQ4ZthLnQVFynp7GDMtbWw2kDmH+tEDFuN8q586HD7pdRsbMEsCxRu3llOQ+HhnIMLaR5RzKaxsf4hvCYOHHhhuLphOVEmkKKh6f7JrzoyuikF5v+BGCNIP8DY8CBJRGJtSP0gEgb7vpFBc9DghJW2mDIMyWr9yJv10omUf/i5kE2J8E2RDgXhady10i7icuyDCCRhrFr4H9M5GClSX5b+uAffFJIEo8tz6ejfFcZeE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR11MB4241.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39850400004)(136003)(346002)(396003)(366004)(376002)(66556008)(66476007)(16526019)(5660300002)(66946007)(2616005)(6706004)(83380400001)(956004)(4326008)(38100700002)(6666004)(86362001)(36756003)(16576012)(6486002)(2906002)(31686004)(26005)(8676002)(6916009)(38350700002)(31696002)(8936002)(186003)(316002)(52116002)(478600001)(78286007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData: =?utf-8?B?V1lYT2lMaWdYZjhqenBjK25TQ0xBN0EraFFOMFlMTjBRdFNaWXBuOEk1VW4y?= =?utf-8?B?U2ROc3Z3S2VUWkd0RTFxczAwYXZpc3FWMEJhWVcwL0NSb095ZjNLSG5ZTEx5?= =?utf-8?B?N0lDUUwxT0grYjliNVEzM1JSNTdsM2FOb1RwKzIralRYMDZuREZubXlPUFFS?= =?utf-8?B?U3RRYmFpN1lwdWp0WkdRMGxKVFpCd2k4RG9LOVlnRS8ranpUOFRYaldFeVlX?= =?utf-8?B?NWIybmpYeG1zUDhxTWhIL29JWU16VSs3Q2ovdjV3eWkrS1l6bzJGRUUxWUEv?= =?utf-8?B?ZGd6VERmUTJxelVTM1IvSWRtY1BCMWRKclQ2WmVTMW9tckE1akc0ZDlmelNz?= =?utf-8?B?QnRsbzZUZUg4RXRlRnl0SnNXd3dUSWtQTitUMytUUjhtV3dRckFnTVl2bGVP?= =?utf-8?B?bHZPa2lHYWxQMWZOcUN5UjJDS2NSblV2OXpET2RwZ0xzVFF0MnV5dCt2QnNq?= =?utf-8?B?aWsvdm5IZE5OWHV5VXppNGxxMmFEVW9pYk13VjdiWGppaXlidk13enJ4bllH?= =?utf-8?B?Ky9QdnhBaDZMV1dTU3ordmNxeWp4TlkxKy9QTmw5MWt5RnVuRGxaMFZoOVhu?= =?utf-8?B?cGRtc01IcFZhbXdqeHA3c1dCcTBvcldYbWRsYnRaa1ZHN21jWmJuZ2p4Y3I4?= =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hnZHlj?= =?utf-8?B?OW5nNkRyTUhid1Bub0thSUt3NXZxQXB1RmxYUk9peGhtSDVseWs4WDdQYllN?= =?utf-8?B?a2lCM2Q2WUFGVXprUW1OdUhUZlFXMFY3ZFJsU2xWMFlJMUlveXBVOTlJOFYy?= =?utf-8?B?QVlzeXYxbUlKVGRaVXFEZE9aTHk5WC85dGxGaTh3RnNDclNPRzBYZTdqRXdX?= =?utf-8?Q?Ug4dlhtfbIRLviS/wX6/W+sCimjhjHmQ/8Hv9wj?= X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: efb53d31-598f-4e90-4cae-08d9001fbab1 X-MS-Exchange-CrossTenant-AuthSource: BY5PR11MB4241.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Apr 2021 15:04:12.9021 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: F6FQ3X+XIfiNVx7V5YWrs+pU3SgDeJDehrYgXcfy+cSs4b6gRkr7EQdbC0wKxz//ZgtX0e24rjzK6jxVRjE/7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR11MB2597 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi experts, I am learning rcu mechanism and its codes. When looking at the rcu_blocking_is_gp(), I found there is a pair preemption disable/enable operation in non-preemption code path. And it has been a long time. I can't understand why we need it? Is there some thing I missed? If not, can we remove the unnecessary operation like blow? diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index da6f5213fb74..c6d95a00715e 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c @@ -3703,7 +3703,6 @@ static int rcu_blocking_is_gp(void) if (IS_ENABLED(CONFIG_PREEMPTION)) return rcu_scheduler_active == RCU_SCHEDULER_INACTIVE; might_sleep(); /* Check for RCU read-side critical section. */ - preempt_disable(); /* * If the rcu_state.n_online_cpus counter is equal to one, * there is only one CPU, and that CPU sees all prior accesses @@ -3718,7 +3717,6 @@ static int rcu_blocking_is_gp(void) * Those memory barriers are provided by CPU-hotplug code. */ ret = READ_ONCE(rcu_state.n_online_cpus) <= 1; - preempt_enable(); return ret; } Best regards, Yanfei