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.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 EE606C433DB for ; Wed, 27 Jan 2021 22:45:30 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9D96A64DD7 for ; Wed, 27 Jan 2021 22:45:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D96A64DD7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=cwqQbSzohURmz0+isB52M14hKVP8HPC0YuZ1dColK10=; b=gAWstTZizB//w6fsqTU/dGEyb KdslRtaKMlyjj2KMp9GKgaIWU/Br0JpkmzxphzosMs93iJqorgAHiiXwV7WmLS8Ivd6ahZP0/fDDo p8FOx6OjPLQmHGdJzfctTHfYeSi/nPa1FghCMfItM1+gZL2h9GPzxW7AmkzEj/AOcSwzgEOJ6XIPA GH7IGJTlcK8D/PZRcoX1mR9gbWA7demaO7U+xKVvne/8lYDR5E47DvgECTz0oaWxPLy6WevX37hR0 SdBMQlGLdwu21+5hlDhJYNwl+Td3i6X/+tEp0SiLUI64jP1WVUlMl3FbffUK2WcOA910BUsiw9jZ7 qifqir68A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4tXa-0006z4-LP; Wed, 27 Jan 2021 22:43:58 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4tXY-0006yi-DS for linux-arm-kernel@merlin.infradead.org; Wed, 27 Jan 2021 22:43:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=7AtM/QmstSC9H7cv+04zDX0FRsehfo4S9RTjsnDMAHE=; b=nT0LngdIoStZ4i+ZhMKCNhEkbq +Ot/Agy4MpX6+i9qpA8LZb8eU8HQCEl/PXudCzCxfjmbl5pVn+p2IBe7pS7STlodegSHfU9NVi6GJ fraU29kjeCS92ldEQrfiqW0lPsU7isyXiVVrkHWcfKBvHqdbgBgwAKB0564qhjxSzAyaqh3i5CO0W vzELGLa+8flwas442njT3SYMXl7nGRHPTd3mgl+EEDBniAsaGjduQiFn/sXdz9KYc86kIt0FZTCQB gpcNMg1FIZCnR2T030iyhDJ752We1w/Ef+x6b636j6v7OeTOcHuHSpjN9tgg2vJ2VXMvZuSID/g+a S7yyrc2g==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1l4tXV-007bu6-Ba; Wed, 27 Jan 2021 22:43:54 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 115A4300455; Wed, 27 Jan 2021 23:43:53 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EF41B200F8CC5; Wed, 27 Jan 2021 23:43:52 +0100 (CET) Date: Wed, 27 Jan 2021 23:43:52 +0100 From: Peter Zijlstra To: Alexander A Sverdlin Subject: Re: [PATCH 1/2] qspinlock: Ensure writes are pushed out of core write buffer Message-ID: References: <20210127200109.16412-1-alexander.sverdlin@nokia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210127200109.16412-1-alexander.sverdlin@nokia.com> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ingo Molnar , Will Deacon , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Russell King Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Jan 27, 2021 at 09:01:08PM +0100, Alexander A Sverdlin wrote: > From: Alexander Sverdlin > > Ensure writes are pushed out of core write buffer to prevent waiting code > on another cores from spinning longer than necessary. Our smp_wmb() as defined does not have that property. You're relying on some arch specific details which do not belong in common code. > diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h > index 5e10153..10e497a 100644 > --- a/kernel/locking/mcs_spinlock.h > +++ b/kernel/locking/mcs_spinlock.h > @@ -89,6 +89,11 @@ void mcs_spin_lock(struct mcs_spinlock **lock, struct mcs_spinlock *node) > return; > } > WRITE_ONCE(prev->next, node); > + /* > + * This is necessary to make sure that the corresponding "while" in the > + * mcs_spin_unlock() doesn't loop forever > + */ This comment is utterly inadequate, since it does not describe an explicit ordering between two (or more) stores. > + smp_wmb(); > > /* Wait until the lock holder passes the lock down. */ > arch_mcs_spin_lock_contended(&node->locked); > diff --git a/kernel/locking/qspinlock.c b/kernel/locking/qspinlock.c > index cbff6ba..577fe01 100644 > --- a/kernel/locking/qspinlock.c > +++ b/kernel/locking/qspinlock.c > @@ -469,6 +469,12 @@ void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val) > > /* Link @node into the waitqueue. */ > WRITE_ONCE(prev->next, node); > + /* > + * This is necessary to make sure that the corresponding > + * smp_cond_load_relaxed() below (running on another core) > + * doesn't spin forever. > + */ > + smp_wmb(); That's insane, cache coherency should not allow that to happen in the first place. Our smp_wmb() cannot help with that. > pv_wait_node(node, prev); > arch_mcs_spin_lock_contended(&node->locked); _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel