Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp781670rwd; Thu, 15 Jun 2023 01:51:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7N6GG4UUsW2+cETadQOqTs265nQ1Zd55oIFeevekxsbTIT1coBQSoygKqirQf9f/1gxUmo X-Received: by 2002:a17:907:d21:b0:94a:653b:ba41 with SMTP id gn33-20020a1709070d2100b0094a653bba41mr4364365ejc.15.1686819070323; Thu, 15 Jun 2023 01:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686819070; cv=none; d=google.com; s=arc-20160816; b=MwhBjb0bApUpsXmFGdpIUuNq2+a2NfOulKRJSqCXAxSn6m3tUKFWHfjJ7MobWtOOp9 0994eOnm23YkI+UJSNJ+IDaW4fccds1Y76Ct/xXaKdA5jbAQwsqFZM8F7QFTHj8l+Dsb flipXYRVCUMbdwjG7Be8xsuPrhlXrZ59NfycHBqXT7zLfVcmIsQb71ASKzdG99GU3wjz x0gREwdx3U/OYrzq9t0grD9lz8onjwjSHYTy3ZAmHmn/myVBccU+OblQ2pDrShvLO5hy 7Re0TUw/EcRqcei46WEweFBhSXahZcL7ImqZg0R5kOeIXAD4nIhIJ7VNN5+NM5F2rgcg NA5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=QvS7bnv1o+6NYe5kDVRIpO6EW5i+31+B+MHL3TfxDYw=; b=g5uczGhy3QccL8hQ498+WpnnRbMj+jP72cWs05WyJ4U9e+UNy40pRM6htyX2J37LfD IRLdI+HsteebfQRO9hbgyZYFAEZmBI7aJXZ2O7gwAaRq138yDg5S1xPIPB6QjjAuFFqI bi6NdV0JFopwFF+ZBWkhMhch25oUhxWJZMqckwMJjQMVYZapdzi06CWc3F5puJW44rqQ 1hgPz/uKgnDKpq2nSfyh8KcB7sBunVPsPv8SBraqt6LOrWvxYVfwt2ToUfxpMBo5T7OP 3uwTcrKxw2WD3+Usltqv2pIRc5S+aXRJGe0idaGdufexOgBvEFnGfeJlZkNfqRFhoPSZ Q5Lw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a17090624d300b00977d57399e6si9506209ejb.938.2023.06.15.01.50.45; Thu, 15 Jun 2023 01:51:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240313AbjFOI2H (ORCPT + 99 others); Thu, 15 Jun 2023 04:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238441AbjFOI2E (ORCPT ); Thu, 15 Jun 2023 04:28:04 -0400 Received: from smtpbgjp3.qq.com (smtpbgjp3.qq.com [54.92.39.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B840C1A3 for ; Thu, 15 Jun 2023 01:27:58 -0700 (PDT) X-QQ-mid: bizesmtp76t1686817663tyrp1h6u Received: from [10.7.13.112] ( [113.200.76.118]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 15 Jun 2023 16:27:42 +0800 (CST) X-QQ-SSF: 01400000000000D0H000000A0000020 X-QQ-FEAT: DWSCcwW/aQbf0QhPLWNXq1lOf4ojSK1+Q6wW+BbzmhGyGUasu1U1SnvEzb0vg CNhQKR+wHg0AKGXycK1IHILDN7NkV+AqCBF7P7vSeIEz5W61P81/aiKvBu+9BNngxhkgsLO g83IXKsUNKl1CObMeDVMOOEnWzZn9oUFyAJqaPccU5l5jeyjK9UmrtkvPlhXdcsvKKyGXv2 VlpbIFMPy1+BiR8oM6tjtVOM6bG8ConWfkWw3VLTTnrPnuYXLp/VeMZf0Mty4wx/IXPoOZc fZ7d8t/BRBcbhT6ycGaCemVDIoETbDfXKKgKBD3tC5+Y3xx1TMg0onlYaCQCXQAD/vWf31t eBgHWj0N+RX3lJdXUDKvi0JnoSqfXXJAiSsuzXy7LA/61pNiUHqf2LaYsPazqVmq4KQsgj9 gx5aTudAjrPmPX2tEXXO9g== X-QQ-GoodBg: 1 X-BIZMAIL-ID: 4872842073552882932 Subject: Re: [PATCH] locking/osq_lock: Fix false sharing of optimistic_spin_node in osq_lock To: Waiman Long , peterz@infradead.org, mingo@redhat.com, will@kernel.org, boqun.feng@gmail.com Cc: linux-kernel@vger.kernel.org, wangxiaohua@uniontech.com References: <20230615012437.21087-1-guohui@uniontech.com> <9f5321f9-0b35-7f85-ee09-247d961e5a79@redhat.com> From: Guo Hui Message-ID: <96DD7021A77A45D4+430029ca-38ee-204a-4ee5-a5246b99bb62@uniontech.com> Date: Thu, 15 Jun 2023 16:27:41 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybglogicsvrsz:qybglogicsvrsz4a-0 X-Spam-Status: No, score=0.3 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On 6/15/23 10:57 AM, Waiman Long wrote: > > On 6/14/23 21:58, Waiman Long wrote: >>> diff --git a/kernel/locking/osq_lock.c b/kernel/locking/osq_lock.c >>> index d5610ad52b92..bdcd216b73c4 100644 >>> --- a/kernel/locking/osq_lock.c >>> +++ b/kernel/locking/osq_lock.c >>> @@ -24,7 +24,7 @@ static inline int encode_cpu(int cpu_nr) >>>     static inline int node_cpu(struct optimistic_spin_node *node) >>>   { >>> -    return node->cpu - 1; >>> +    return node->prev_cpu - 1; >>>   } >> >> From the first glance, the patch looks OK. The only issue that I have >> so far is the "node_cpu" name which is misleading in this case. You >> should have renamed it to node_prev_cpu() instead as there is only >> one caller. > > One more thing. Unlike node->cpu, node->prev_cpu is subjected to > change. So you should have use READ_ONCE() to read it to match the > WRITE_ONCE() that modifies it. > > Thanks, > Longman > > Ok thanks, I got it.