Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1990791iog; Sun, 26 Jun 2022 03:59:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHwOOSlrcNmlNXrr6/v1rGKpwsNLk/cetFYOqWAatjaXNPuyj5qbC82DPVzoJ2LIWDvyPR X-Received: by 2002:a17:907:7e82:b0:726:4211:60e7 with SMTP id qb2-20020a1709077e8200b00726421160e7mr7208691ejc.665.1656241158563; Sun, 26 Jun 2022 03:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656241158; cv=none; d=google.com; s=arc-20160816; b=Nfc9BH+jRvR0QV7ySSstcAQ81jIXhzfhRTa9+MohX7iWKM4CqVpEqLsQQJAAE8cJRE vx5eXHqDDzd2HmdlV3Mkjm5e7UIGa3nrEOL2E9bw9ZctXrnRelnVGiv20G++6tOdqx9O zQnXg5Wmp0hCK4drDRF1mYY0RnyemYU4RtQMATpQ0wxL6RPi29yVgQyh9c2eLNTDFOQ8 2r9CTYD//MRUdtkSQVtJ5DMJl0KZDiIbRJBAx1ZyH/VOLj1khJVkBq5CBZ0gNH9deBZI w7IeYXz661TFY7XLFTVi64nj/NoD9j6wHb3pMDNEOmxcbF9RyNhTEnw9mtRCM8x6UMGU ntwg== 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=6InSV56Wmf/Ott/MhJFHAADQ4Uv/vbzwSYycypoeAmU=; b=Y189Mf8gMnk8xG7B36uKUqN5b/t+54rZK3vjJoJ2+1Ii3JJ7RidQvbiDbPtUOwPQCx KECw3lJPbtzyw52km5lq+FkNtL6mbYVw8ZBTDeAexiAyI/OaYjqqjfnFrkZtfW6BQGRb JCne7XHZ25yKfAt6S7UxR9Rqjhc2Bk7Duk5O/zVq7bdzFalCn3Ogw+vl4slDVWoNj7M6 rW4nCTAqm3G7l2rWPO4d+3EwVA0F3Eaw5/TtzCm83rrAJxE+g1iuxTXbsHPuGu/e4vbt oIyCCdtj5sx/5gHBMZ8h5cMzE7w8YbF7Y+3lzKP5zlYv52qolss19BAZeIHEmp0isg5i SC7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KGHUo4VX; 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 gn24-20020a1709070d1800b0070f257ba384si11305281ejc.661.2022.06.26.03.58.51; Sun, 26 Jun 2022 03:59:18 -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=KGHUo4VX; 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 S233873AbiFZKph (ORCPT + 99 others); Sun, 26 Jun 2022 06:45:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229531AbiFZKpf (ORCPT ); Sun, 26 Jun 2022 06:45:35 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0711212AF7 for ; Sun, 26 Jun 2022 03:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656240334; 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=6InSV56Wmf/Ott/MhJFHAADQ4Uv/vbzwSYycypoeAmU=; b=KGHUo4VXOvfGNCE09P3s2QdatZ7Knyol/DpP8UIzLBuoT4urV/hWTi2gXbbb5/uihfPR7k qBMOGHGq5MqkR/nXzzS08YhU8NcjYD9N3dBKbx5gYjBnX6/iwctHM3VPsWe+2ISG5MAswl 70+pWTk8+9rrSlAKPdKQaS32CyN8E7c= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-slomwFmrMKqalepE5Ds0-Q-1; Sun, 26 Jun 2022 06:45:30 -0400 X-MC-Unique: slomwFmrMKqalepE5Ds0-Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 04D3D1C01B23; Sun, 26 Jun 2022 10:45:30 +0000 (UTC) Received: from localhost (ovpn-12-101.pek2.redhat.com [10.72.12.101]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 26EF91415108; Sun, 26 Jun 2022 10:45:28 +0000 (UTC) Date: Sun, 26 Jun 2022 18:45:25 +0800 From: Baoquan He To: Valentin Schneider 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 Message-ID: References: <20220620111520.1039685-1-vschneid@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 06/26/22 at 06:37pm, Baoquan He wrote: > On 06/24/22 at 02:37pm, Valentin Schneider wrote: > > 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. > > You are right. I only checked the code comment in this place. Then this > patch looks good to me, thx. > > Acked-by: Baoquan He OK, just saw Eric's comment after I replied.