Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp511396rwd; Wed, 14 Jun 2023 20:35:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BdVL6d/ATCiKtaGoLg4d9D+dKSUsEy37XJ0KkHeYdmWZYLD1aai88P/MRx9xszf1rlWLj X-Received: by 2002:a50:ed85:0:b0:518:7415:3b61 with SMTP id h5-20020a50ed85000000b0051874153b61mr4195359edr.23.1686800154150; Wed, 14 Jun 2023 20:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686800154; cv=none; d=google.com; s=arc-20160816; b=CoXBHkcZ+0OZHGIP8LI41f7hYjGX5S0Iw20wmuiQTIOibfefrwUFPI12p0kKOu7xm1 FeTYfWt87R3WVonlU4ZLz4KGm3pYE5+ZdPEaxdsc36dN2mEMt3Taeu+Ijurta14rs9pV V4ayElBkE6IfHlKiMrYfaFRh87W9oNE/0i0oQJptFGHPun9MGYvxSVm4mnwsKjzlTa5L 4vKO1JdbFArLELyrVH72RlXXlafsIdIu4dLe45Vs8h/GGFhiI6mNv8OKL7kZszBvZ9Jk t19d1XN562zPSwb6z15Uj1IcdXcLufIkJpAI90qRrG3Z0mHlPCFpcVMmZIz24dZAvCTo 4kKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=3NIislaoMeApemHv5x6Quq/pA/Iddn6wkpmNpNKXL1I=; b=0Jk/WA21YHseAz74TtA8dDgCMl9ZXx/miONnSu3lCogQ/tlHh5rwTJ/7J70tBjJIsH lxlhhAERkRA3ns/bHXW1Js8H3H7Q10jDL0m9mwjIc8x2HHVxJxYWf+/aUNHw6FNR6bIO uB4yDreT2xOXFr5sFOikeINlUuok58oaW6iAcnTiUcdadfpckjpyK9MPGoisN3xmsfDH CIXoY49I0niQidDm+s1Tg9DGRkK2rF8eg7EpOCFoSy3i60BkreqiGfDNKHKLkMdgIyMh 6okPXe+frcsbvQ6puC+TsBp7jYOR3nvJKW/QWB1CnhMVY18dDDObG21lOjjMYUITB//k gggg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=BLeR1iVz; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u26-20020aa7d0da000000b0051869e5d4dbsi3650766edo.605.2023.06.14.20.35.29; Wed, 14 Jun 2023 20:35:54 -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=@redhat.com header.s=mimecast20190719 header.b=BLeR1iVz; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237040AbjFOC6P (ORCPT + 99 others); Wed, 14 Jun 2023 22:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229558AbjFOC6N (ORCPT ); Wed, 14 Jun 2023 22:58:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 502EF26AF for ; Wed, 14 Jun 2023 19:57:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686797847; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3NIislaoMeApemHv5x6Quq/pA/Iddn6wkpmNpNKXL1I=; b=BLeR1iVzJD9V82z/pI/5nDGlcO2v3ciDdV6D+IodlQzAIe5t6fqp/Ov9aJDq5ruQoUs2JK xI4oqYUTgBJHtXN9NudSGAJL/JW06QnQ8+XX0C0Fb6Vfvfw5Khrf86Qs2nIm9TeNpJz8Yu JBFotPwnGEiYpyW/Gxx726Wlf1TqxkY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-549-dr9fIxELNaisgioBgFe7-g-1; Wed, 14 Jun 2023 22:57:24 -0400 X-MC-Unique: dr9fIxELNaisgioBgFe7-g-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 85CAC101A52A; Thu, 15 Jun 2023 02:57:23 +0000 (UTC) Received: from [10.22.16.11] (unknown [10.22.16.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 235AB400DEFC; Thu, 15 Jun 2023 02:57:22 +0000 (UTC) Message-ID: Date: Wed, 14 Jun 2023 22:57:22 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH] locking/osq_lock: Fix false sharing of optimistic_spin_node in osq_lock Content-Language: en-US From: Waiman Long To: Guo Hui , 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> In-Reply-To: <9f5321f9-0b35-7f85-ee09-247d961e5a79@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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/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