Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp1284770ybd; Wed, 26 Jun 2019 14:49:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhtqKHi07lRI6dXrtAUrT/YeiWGnui4XO6TYChZSIlxxnFHi2brNDaIgTzvdy/2TRlNI+B X-Received: by 2002:a17:90a:e38f:: with SMTP id b15mr1570361pjz.85.1561585798723; Wed, 26 Jun 2019 14:49:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561585798; cv=none; d=google.com; s=arc-20160816; b=CQvzH84WOymsZcgLeoxs2E5w7gP0p3SRdEq2oVAvG8dwE2pVNSqqwH7AnBzQ8iU4Wv dZz7GeTB16y5rKs9ILmTY1nUP5kJ0WokGVzECFresDJuToCASDF/QlP5x6r6XXuGsFxW Ri0GIYeKyCRyDrk4clYYZZTHur1Biw/b8BL0aomhUjBShSqX6dJquqVv4ZeGOXu1v7U/ 8jMm1tqcQFepplDsCBG9rYXkRf9/DHtwVTh0HSBjdFGKvVk8ByRDXp4TcmgT+LF32gW2 BkcfyXxSd+uDHJvvucg7m7PtthnrQDYDdT5TkC6ISHA+h6r+iHdOn0He6BiGqhOghudE G8ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=ABc0j6sYsLWcMAGTGfKpu7EkxXTxZET/+A8IKZBOp1Q=; b=hI+p4MOtsatNURfQJXJgI9c+kAtm3/emB4qbaN/1zysT9KDc/IOa77k1IdK6eJVJNF +YWBrjietVjCNq0Svj8Bu7PfvgdGroDRTfKXwUYVlJKZTlWiZ0Fe2ZQkemS6aA0WcAz/ hUxFZPk0+hPKzMgiTuYx4OlwXwdZJPlgX5c79Zngw3T1DcNegRg30jrgg67MvbxoCxN5 I/L5zVC2TiHZflqhFIzDawzpQNeGMeIK1pc1ySkId1T5/q0Ve9KjXYcBFKycQ69PUZyK uqLqTwSwghMvTGRdv0pR+T6zQSc1MoP2xbXZG5Fkv0irODRHbAdpZq6fGKpbikN6Z8dy QdBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cb13si292526plb.325.2019.06.26.14.49.43; Wed, 26 Jun 2019 14:49:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726445AbfFZVr4 (ORCPT + 99 others); Wed, 26 Jun 2019 17:47:56 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:50412 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726223AbfFZVr4 (ORCPT ); Wed, 26 Jun 2019 17:47:56 -0400 Received: from p5b06daab.dip0.t-ipconnect.de ([91.6.218.171] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hgFlW-00088d-0n; Wed, 26 Jun 2019 23:47:42 +0200 Date: Wed, 26 Jun 2019 23:47:40 +0200 (CEST) From: Thomas Gleixner To: Fenghua Yu cc: Ingo Molnar , Borislav Petkov , H Peter Anvin , Peter Zijlstra , Andrew Morton , Dave Hansen , Paolo Bonzini , Radim Krcmar , Christopherson Sean J , Ashok Raj , Tony Luck , Dan Williams , Xiaoyao Li , Sai Praneeth Prakhya , Ravi V Shankar , linux-kernel , x86 , kvm@vger.kernel.org Subject: Re: [PATCH v9 09/17] x86/split_lock: Handle #AC exception for split lock In-Reply-To: <20190626203637.GC245468@romley-ivt3.sc.intel.com> Message-ID: References: <1560897679-228028-1-git-send-email-fenghua.yu@intel.com> <1560897679-228028-10-git-send-email-fenghua.yu@intel.com> <20190626203637.GC245468@romley-ivt3.sc.intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 26 Jun 2019, Fenghua Yu wrote: > On Wed, Jun 26, 2019 at 10:20:05PM +0200, Thomas Gleixner wrote: > > On Tue, 18 Jun 2019, Fenghua Yu wrote: > > > + > > > +static atomic_t split_lock_debug; > > > + > > > +void split_lock_disable(void) > > > +{ > > > + /* Disable split lock detection on this CPU */ > > > + this_cpu_and(msr_test_ctl_cached, ~MSR_TEST_CTL_SPLIT_LOCK_DETECT); > > > + wrmsrl(MSR_TEST_CTL, this_cpu_read(msr_test_ctl_cached)); > > > + > > > + /* > > > + * Use the atomic variable split_lock_debug to ensure only the > > > + * first CPU hitting split lock issue prints one single complete > > > + * warning. This also solves the race if the split-lock #AC fault > > > + * is re-triggered by NMI of perf context interrupting one > > > + * split-lock warning execution while the original WARN_ONCE() is > > > + * executing. > > > + */ > > > + if (atomic_cmpxchg(&split_lock_debug, 0, 1) == 0) { > > > + WARN_ONCE(1, "split lock operation detected\n"); > > > + atomic_set(&split_lock_debug, 0); > > > > What's the purpose of this atomic_set()? > > atomic_set() releases the split_lock_debug flag after WARN_ONCE() is done. > The same split_lock_debug flag will be used in sysfs write for atomic > operation as well, as proposed by Ingo in https://lkml.org/lkml/2019/4/25/48 Your comment above lacks any useful information about that whole thing. > So that's why the flag needs to be cleared, right? Errm. No. CPU 0 CPU 1 hits AC hits AC if (atomic_cmpxchg() == success) if (atomic_cmpxchg() == success) warn() warn() So only one of the CPUs will win the cmpxchg race, set te variable to 1 and warn, the other and any subsequent AC on any other CPU will not warn either. So you don't need WARN_ONCE() at all. It's redundant and confusing along with the atomic_set(). Whithout reading that link [1], what Ingo proposed was surely not the trainwreck which you decided to put into that debugfs thing. Thanks, tglx [1] lkml.org sucks. We have https://lkml.kernel.org/r/$MESSAGEID for that. That actually works.