Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp926926rdf; Wed, 22 Nov 2023 00:08:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIRn7IHzLznanaZhIq7FGtq90Mwlolds8JQVrvpWZ4wgh085N/d0GMqBlm6K0yGbTZT1Tb X-Received: by 2002:a05:6808:428c:b0:3b2:e765:9beb with SMTP id dq12-20020a056808428c00b003b2e7659bebmr1538245oib.56.1700640487786; Wed, 22 Nov 2023 00:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700640487; cv=none; d=google.com; s=arc-20160816; b=HlARtvzEkCeFGBCAM02qfeYp9mV4RQiF/vavS1EouM95MOGCb2tYWImAom7zFPF4+O U5oV5ebwwqePrEDQEvEXFT0tNfs7mWlMuywIyEz+Cc45tUK2G7k38PYrs8Yac2PqwwXm 9CAbhhJEszGyjWYipBWQr7x5x+swGzyVT1GM6w/Wx7ynKgo49toHNizBhqTAZaE2xLxf m6wnxU5zC8Dq1e9x2dW3JCET5QTDDhLePmHlGHc6mHZ2TxowkvO9jveVyNSUJ/8Axu5s FGbEQsu6IT7P+Bv1ZWES1XRYSoMkSznMyw7EoY7cxjsD+QOe14cb8R5VTOXdGlYbGOxI lnog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MTL9eS606aR4jOsPXUpex7owGMXk2Et9Dz0AzsPRhrM=; fh=LWRGkcqkHkFT3P1oP6KE8wwXM8Rehutas5LsZGaIIS0=; b=ewyMfcCjynDtrFZjdcOOkOEAHtQFmSasC7pfEqI6X3J0+z+Jg7aHgGQqEMoq1dcdNB ZrMzVCYtD0lixk2bDaqOJSR8nVKhuc2jP221Nc2pX/HX+44YS0kVIaPSQIXqqH/lS63u qjAHfBMYefOtJmmHKBgy/bVhskiKINYFQkEpup5oaZLLPtA8xBxN1+Hc12/o8tLa9eou nX8nQPLJGOf3lqc6k1TOGWVgCgQ2wJweV9FZQUsZlDx9aNMCR1g3NcKQ19wwvsx9Eott 61esuxySaOL1/6LDHoQG0TEfj5tZI5o1pMXVidu225g+hwn5pAa19xtpYD+cXKVNhSzo 1BFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dPqcJxBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id 15-20020a63104f000000b005c1e78daf17si12307894pgq.485.2023.11.22.00.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 00:08:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dPqcJxBK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 910F48073298; Wed, 22 Nov 2023 00:08:04 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234945AbjKVIH4 (ORCPT + 99 others); Wed, 22 Nov 2023 03:07:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbjKVIHm (ORCPT ); Wed, 22 Nov 2023 03:07:42 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA33110CB for ; Wed, 22 Nov 2023 00:06:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700640408; 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: in-reply-to:in-reply-to:references:references; bh=MTL9eS606aR4jOsPXUpex7owGMXk2Et9Dz0AzsPRhrM=; b=dPqcJxBK8wfF0Ab39Nq99OhcWMkpbooCKOShxE37teHU5ZfIsuTkC7s0ww9CkihSJf45lH SfkSdwTr0exDICPGnrAP9qulmoopAwiVV2aQzwj1DDwfsElxalla1f4PMZIH+jGg6SEqM9 MQ2rEu1VWf0JcgQtycjPbAe23NXj/5A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-558-RLq--aGvM8SKDDM51CwVDA-1; Wed, 22 Nov 2023 03:06:47 -0500 X-MC-Unique: RLq--aGvM8SKDDM51CwVDA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 63FCF185A780; Wed, 22 Nov 2023 08:06:46 +0000 (UTC) Received: from localhost (unknown [10.72.112.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 531AA36E2; Wed, 22 Nov 2023 08:06:42 +0000 (UTC) Date: Wed, 22 Nov 2023 16:06:39 +0800 From: Baoquan He To: Uros Bizjak Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, Eric Biederman Subject: Re: [PATCH] kexec: Use atomic_try_cmpxchg in crash_kexec Message-ID: References: <20231114161228.108516-1-ubizjak@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231114161228.108516-1-ubizjak@gmail.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 22 Nov 2023 00:08:04 -0800 (PST) On 11/14/23 at 05:12pm, Uros Bizjak wrote: > Use atomic_try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in > crash_kexec(). x86 CMPXCHG instruction returns success in ZF flag, > so this change saves a compare after cmpxchg. > > No functional change intended. And code is simplified a little bit, so looks good to me, Acked-by: Baoquan He > > Cc: Eric Biederman > Signed-off-by: Uros Bizjak > --- > kernel/kexec_core.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c > index be5642a4ec49..bc4c096ab1f3 100644 > --- a/kernel/kexec_core.c > +++ b/kernel/kexec_core.c > @@ -1063,9 +1063,10 @@ __bpf_kfunc void crash_kexec(struct pt_regs *regs) > * panic(). Otherwise parallel calls of panic() and crash_kexec() > * may stop each other. To exclude them, we use panic_cpu here too. > */ > + old_cpu = PANIC_CPU_INVALID; > this_cpu = raw_smp_processor_id(); > - old_cpu = atomic_cmpxchg(&panic_cpu, PANIC_CPU_INVALID, this_cpu); > - if (old_cpu == PANIC_CPU_INVALID) { > + > + if (atomic_try_cmpxchg(&panic_cpu, &old_cpu, this_cpu)) { > /* This is the 1st CPU which comes here, so go ahead. */ > __crash_kexec(regs); > > -- > 2.41.0 > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec >