Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4454833rwb; Tue, 20 Sep 2022 14:18:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7YzibiZojru9BZiICgTtQnF0l6kLM2evLnoLCm4sWEqrJgSioZBpvFrDOtYTMLy1gHxLdG X-Received: by 2002:aa7:c9c4:0:b0:452:1d98:1be3 with SMTP id i4-20020aa7c9c4000000b004521d981be3mr21831964edt.289.1663708737719; Tue, 20 Sep 2022 14:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663708737; cv=none; d=google.com; s=arc-20160816; b=VjQAl4xpH+dPzjgbjsfUjNOZTAX231n4rQ7aC3cHnchL6qOXGaLlL5gh7LduX2lsof LkUz/liGU0+j4hRfP1j3BPWaxwz6SCtnduJ9jJpfB9zbNsApPJCWwm5eWQKerI75pg05 UHIFJwh6Pnb73r7x3Qoea39BR7eel5iNtx5/3bsO9U38z12gY3zCrnfpvkPUnjs4v+r/ fefOi0o1p/tJxZzulsAD+VjyN4xzxyXeXkTozIyAmRTUltLNmXRby+giHX9QTBTGS2eT RpE1ZGAYdgfNFPHbhoM+m1utWdsngncEcRYDAzY1TNdZzZiIqvCO7CRXF7vEdk+xI4ig Qsxw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=dndBUUyTd8Rbt5rH1+UqxAoWeyUi1+M1Mj7FGWIu6ys=; b=rEXmYWaNdVpTsxonUA84gvz/G+1Acwn1ckLoXyyVEPFG/tm28t3Ve/yugCQfOW8uqt jU9/ERbAM6Et/+Bx/oapHk8WkfudCATOJ4nekNW6foTyoZsg6yX2BhZjVvNIRcazfMHc RfHK2z3ciWNN7rfE0H7eb8ezvxiMWLgeyql1moAEyQCMZPXrcqn+wIpMr3mvzsBNuSJY rRgXVw5XT/6f0FElSSRUBIydGBAWqiGMsu0Y8sK0uBg11exscRO2AUIC2SRWWmgSKfC2 a4P3b2gcDZvAFaW3P8mQVmjuVSs4yfWGUTrI6Om2NJX3Na/Z8XJFVJxFtMHP9PL8x3wZ qMqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U7otvNj+; 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 jl14-20020a17090775ce00b00741a0720a2bsi563244ejc.814.2022.09.20.14.18.26; Tue, 20 Sep 2022 14:18:57 -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=U7otvNj+; 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 S230352AbiITVEx (ORCPT + 99 others); Tue, 20 Sep 2022 17:04:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229847AbiITVEp (ORCPT ); Tue, 20 Sep 2022 17:04:45 -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 DC13DE0AD for ; Tue, 20 Sep 2022 14:04:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1663707880; 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=dndBUUyTd8Rbt5rH1+UqxAoWeyUi1+M1Mj7FGWIu6ys=; b=U7otvNj+AURB4XDxgQTRd8Sexo49EgnBCuI5/YLgP0gPjpqQ3t6dXgrfSZQg5LT090dVbF xxyScyK0WopElQbHk36hdksA4lSyJ69koGmZyNFNCaGa7h/MTl8s/vOsqL8mzw1GGHweNU OJ1JEkanduzsGsLT56SGXigkQvB4i8k= 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-379-SJmcUg02OIm0wnXFFQkUtQ-1; Tue, 20 Sep 2022 17:04:36 -0400 X-MC-Unique: SJmcUg02OIm0wnXFFQkUtQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D92B882823; Tue, 20 Sep 2022 21:04:36 +0000 (UTC) Received: from [10.22.34.82] (unknown [10.22.34.82]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D08BC15BA8; Tue, 20 Sep 2022 21:04:36 +0000 (UTC) Message-ID: Date: Tue, 20 Sep 2022 17:04:35 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [PATCH v2] locking/qspinlock: Do spin-wait in slowpath if preemptible Content-Language: en-US To: Peter Zijlstra , Ingo Molnar , Will Deacon , Boqun Feng Cc: linux-kernel@vger.kernel.org References: <20220920195542.1548164-1-longman@redhat.com> From: Waiman Long In-Reply-To: <20220920195542.1548164-1-longman@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Spam-Status: No, score=-5.0 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_LOW,SPF_HELO_NONE,SPF_NONE 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 9/20/22 15:55, Waiman Long wrote: > There are some code paths in the kernel where arch_spin_lock() will be > called directly when the lock isn't expected to be contended and critical > section is short. For example, tracing_saved_cmdlines_size_read() > in kernel/trace/trace.c does that. > > In most cases, preemption is also not disabled. This creates a problem > for the qspinlock slowpath which expects preemption to be disabled > to guarantee the safe use of per cpu qnodes structure. To work around > these special use cases, add a preemption count check in the slowpath > and do a simple spin-wait when preemption isn't disabled. > > Fixes: a33fda35e3a7 ("Introduce a simple generic 4-byte queued spinlock") > Signed-off-by: Waiman Long On second thought, I believe the proper way to fix this is to make sure that all the callers of arch_spin_lock() has preemption properly disabled. Will work on another patch set to do that. So please ignore this patch and sorry for the noise. Cheers, Longman