Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp441545iog; Fri, 24 Jun 2022 07:04:54 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vFu4p87BFqh/H6aRlupNTTEAbQBBBYiDV+TReHw8g2VwlAsh3kHxI88xyOwQXZKXtSHkkP X-Received: by 2002:a17:902:b94c:b0:16a:5019:5be3 with SMTP id h12-20020a170902b94c00b0016a50195be3mr11607140pls.10.1656079494037; Fri, 24 Jun 2022 07:04:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656079494; cv=none; d=google.com; s=arc-20160816; b=Q7pQHQGvis4sp0lIFriYRAxMER1I1Ew/jARBCk1205KFVDSfYQ5pGLznhE6LYqLteX s0L5q4D6sFm2ZNKdUiaITdgtbwza7ZZg/t6WUw5CUNeYPeRDgR/rSVP7JdJtQfS5U2go hYHP5PLqIP3FSpW3HhjEgaMB6mllDxDvee8ES6xlDZFqy1txQYBpIqL0kN/4sAAwBqfV qwwP8x0ICpKc68MiIZihTimJoZHMxpmT2DmLiRQkOI8XPzRiC1Fz556FzZ2sXN+Np9Ee IL/N5NKPI1Reu5IxKbkOwfl6HVnolZbCrSz247l+pAbC7LITHN2RF08fUA2dIJHkM9Fe vqxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=iihGsDJaCfgB0U9H9bTk3P+5uHXU2Udgo4mdhsEY1hk=; b=oOfA5GWgf6sc5hDbWMYwHChj+jNo9ABYNtrOsdupUzC+ejcuw0hDMmrUolx+F4KgN3 Lj+gwx9vN7HUCTWNBNLX+2uW/mTNZZslNc80k9BMhI0UImZFZZyYT3ULw9x8ByQ4Zyea J5n7RrX/51sgxIgcH4fLJ4mnZDccIH8SNW1rFmiSzoCyvNfuMka7S/qcnA96zXDc4ffJ DVWG7YubQD6WekrG29miHuZtHfEcIaEHxMDoPOyDWVLwIAo0NIM4nDlU+FZnS84280Oj j8NZa59J4F93yUwpnFsztmkRTMTtfQpZ9WWNIPZSAv9id8EgfLT+MZ40z6jvzfxUAUeJ QamQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Royy/kYS"; 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 s23-20020a656457000000b0040503f6fc58si2797118pgv.292.2022.06.24.07.04.38; Fri, 24 Jun 2022 07:04: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="Royy/kYS"; 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 S232210AbiFXNiA (ORCPT + 99 others); Fri, 24 Jun 2022 09:38:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232266AbiFXNht (ORCPT ); Fri, 24 Jun 2022 09:37:49 -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 ESMTP id 01BFB52E5B for ; Fri, 24 Jun 2022 06:37:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656077858; 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=iihGsDJaCfgB0U9H9bTk3P+5uHXU2Udgo4mdhsEY1hk=; b=Royy/kYSZQmbA8kjAokE+eg67UWwe37hREQM4pAAKdvjOxKJdJ/Nc/7waUVv9pfXgk0qWq mBO+ZUUq3HLE9NYqMiI3JUiglLRwiSwLwSkl494rV9mXJ+nffqdlipTAHZHO8eL9Sp4N4V QRNoHE2e3XrD9PjIfqJASy/GpWvrJ6g= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-9iHzjYXuO1KmlERCulCrrA-1; Fri, 24 Jun 2022 09:37:36 -0400 X-MC-Unique: 9iHzjYXuO1KmlERCulCrrA-1 Received: by mail-wr1-f70.google.com with SMTP id s7-20020adfbc07000000b0021a558c09b4so341022wrg.4 for ; Fri, 24 Jun 2022 06:37:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=iihGsDJaCfgB0U9H9bTk3P+5uHXU2Udgo4mdhsEY1hk=; b=asbpT29KYA6T0mQT/x5xhUgpfG3ZBCVZrz1sST1u4Do+p3iWh9ChmYRcqLoyZs3INW BT4m70+ZXXtO0IEGZHVuTnQflTPMlcpcGmhyoE1qn965ygpAhDEsBuuJgdty/ytm8VC7 1cTVmsKWqUrCpKTUQUv5sRhjlF/00y6gCl06WefFyHHGDO1bglFPqgrwz8a6Fvd6nw3N 1PsCFLK67BWsbIdN9lepkb27vliDvkodRlD2nWQSja1c7P6Fn/fTfM3TzUrrDlHxFELt N48EiwT1i05oBGGJlKaTW5Sdv8ydm6az1m70+qrB2oavhDROtef9mzalBmiTP0J0Ncxt 2PqA== X-Gm-Message-State: AJIora8WQK/r+c89AlDREl/wjxWfD3c+Z0kIU8Mxz3FwYQHr17PQEmQc ZzCBLQC6FqOuXsNSiVb40Uf2YkAZytyG7Z2226a9ScvaTKx4EZMTG7ADZgVj9xafxe7zYzGcUQK vUHC+ZZG1E7z++vNHBQVXV3G+ X-Received: by 2002:a05:6000:1373:b0:21b:ae65:cd38 with SMTP id q19-20020a056000137300b0021bae65cd38mr5758329wrz.323.1656077855326; Fri, 24 Jun 2022 06:37:35 -0700 (PDT) X-Received: by 2002:a05:6000:1373:b0:21b:ae65:cd38 with SMTP id q19-20020a056000137300b0021bae65cd38mr5758301wrz.323.1656077855110; Fri, 24 Jun 2022 06:37:35 -0700 (PDT) Received: from vschneid.remote.csb ([185.11.37.247]) by smtp.gmail.com with ESMTPSA id h6-20020adffd46000000b0021b96cdf68fsm2300843wrs.97.2022.06.24.06.37.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 06:37:34 -0700 (PDT) From: Valentin Schneider To: Baoquan He Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-rt-users@vger.kernel.org, Eric Biederman , Arnd Bergmann , Petr Mladek , Thomas Gleixner , Sebastian Andrzej Siewior , Juri Lelli , "Luis Claudio R. Goncalves" Subject: Re: [PATCH v2] panic, kexec: Make __crash_kexec() NMI safe In-Reply-To: References: <20220620111520.1039685-1-vschneid@redhat.com> Date: Fri, 24 Jun 2022 14:37:33 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, 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 24/06/22 09:30, Baoquan He wrote: > On 06/20/22 at 12:15pm, Valentin Schneider wrote: >> @@ -94,14 +94,20 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, >> /* >> * Because we write directly to the reserved memory region when loading >> * crash kernels we need a mutex here to prevent multiple crash kernels >> - * from attempting to load simultaneously, and to prevent a crash kernel >> - * from loading over the top of a in use crash kernel. >> - * >> - * KISS: always take the mutex. >> + * from attempting to load simultaneously. >> */ >> if (!mutex_trylock(&kexec_mutex)) >> return -EBUSY; > > So kexec_mutex is degenerated to only avoid simultaneous loading, > should we rename to reflect that?, e.g kexec_load_mutex. > It's also serializing crash_get_memory_size() and crash_shrink_memory(); more generally it should still be the preferred serialization mechanism as it's a "proper" lock visible by instrumentation, the atomic variable is a side character for the NMI case.