Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp269681pxb; Thu, 27 Jan 2022 21:29:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLDiGmly55w9Bfo1snxC69gLvIVk7gSkI9QXI74TEajGOqDqRqiIpBCw2U9r/9+jxku0o+ X-Received: by 2002:a05:6a00:1a50:: with SMTP id h16mr4241923pfv.74.1643347794514; Thu, 27 Jan 2022 21:29:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643347794; cv=none; d=google.com; s=arc-20160816; b=xqFG5aidKQM1jLEslsOVBkh7xB2xcMdGAsEZ1DHB0DB/+EhyDyrG0BvIggua0oQO/1 QQ8biq4q+8HiyyF2xEBCTNKP9lWeyD0kyPGi629LJ3twrRX1R2D1nIJC9Ck9/z6W4w92 pin2ChIls4bHppyMusHSiVll+hYrBDavJ4WwakoQwYF96rgz+I7vs2iFDkg6lnXpMO5j H7Q8xbxJ2pOjbK7oP0ynkbD07DQm88PZjF/N80C5vy8lEGfCWziTeHOmkWZyQj9sc9I3 /zZxPIm0S2IupBb8tQw5DXMYqjjDfdJJbqHmVjh08nhPbsIM4Al6O8vpRGrpNXTuqHhP aWtw== 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=tbSBDUBhM1VKVepUEI40R+PoPjZ1FBHKtQVTPFDsqko=; b=Mrvt5kkWRMg4b18KhlXt7Gxo7tDTqBkBolmdcMQko+irLHDffNyn64SQzRagImFfOM YzcaVlfMALwykiZTyo+GnMNYGBYaeoEyLDfaJvtgeQL4hayd7jgFpkytpVUTijfGvow3 R4WCch9VUeLGlzknrO+A8dxqlCO425dL0zl3/lXALo3mqOnXfCHTe5yZXPmJh89oc7AB ZDoTo85nAguBEyRqkNqEL2wozsq7CH+tjlehFYbV+Oa5hAE7ZiN9jGuwgVL6DMvwpbqh RMwx2S/73mGed/KoYRdfMQ/UcQiLs6Cu7/y6jMApa9sizBg7W4UPJ44tQeSqeN2wCDFX acFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rFhS1eDv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h123si4552396pgc.414.2022.01.27.21.29.28; Thu, 27 Jan 2022 21:29:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=rFhS1eDv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242329AbiA0OZ7 (ORCPT + 99 others); Thu, 27 Jan 2022 09:25:59 -0500 Received: from smtp-out2.suse.de ([195.135.220.29]:39276 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229755AbiA0OZ6 (ORCPT ); Thu, 27 Jan 2022 09:25:58 -0500 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 36B651F3AB; Thu, 27 Jan 2022 14:25:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1643293557; h=from:from:reply-to: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=tbSBDUBhM1VKVepUEI40R+PoPjZ1FBHKtQVTPFDsqko=; b=rFhS1eDvIlJ4RlzwqI6YDiT+s0/bb1RTP/fMzY7Nby8A8t3eMv/+fjCpQB3GosK6tZEYhJ n+p/eZ8SXzJenUyhVtKyOYeRXRkInTFaSQbyp8xWfFpTLZrE5EbaXcw1QhSNSZg5IWAGRF LDRP1phCDX5Dgt4hUs5GeIfzJ+1F5RA= Received: from suse.cz (unknown [10.100.216.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C2E13A3B84; Thu, 27 Jan 2022 14:25:56 +0000 (UTC) Date: Thu, 27 Jan 2022 15:25:53 +0100 From: Petr Mladek To: John Ogness Cc: Sergey Senozhatsky , Stephen Brennan , Steven Rostedt , Sergey Senozhatsky , linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/4] printk: disable optimistic spin during panic Message-ID: References: <20220121190222.572694-1-stephen.s.brennan@oracle.com> <20220121190222.572694-3-stephen.s.brennan@oracle.com> <87r18un83x.fsf@jogness.linutronix.de> <87tudqwegy.fsf@stepbren-lnx.us.oracle.com> <877dalpcvz.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <877dalpcvz.fsf@jogness.linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2022-01-27 13:49:44, John Ogness wrote: > On 2022-01-27, Petr Mladek wrote: > > I mean that chance of dealock caused by the internal semaohore spin > > lock is super small. In compare, a lot of tricky code is guarded > > by console_sem. It looks like a big risk to ignore the semaphore > > early in panic(). > > Agreed. > > > A better solution would be to use raw_spin_trylock_irqsave() in > > down_trylock(). > > down_trylock() is attempting to decrement a semaphore. It should not > fail just because another CPU is also in the process of > decrementing/incrementing the semaphore. IMHO, it does not matter. As you say, raw_spin_trylock_irqsave() fails only when another process is about to release or take the semaphore. The semaphore is usually taken for a long time. The tiny window when the counter is manipulated is negligible. I mean, if down_trylock() fails because of raw_spin_trylock_irqsave() failure then it is few instructions from failing even with the lock. > Maybe a down_trylock_cond() could be introduced where the trylock could > fail if a given condition is not met. The function would need to > implement its own internal trylock spin loop to check the condition. But > then we could pass in a condition for it to abort. For example, when in > panic and we are not the panic CPU. This looks too complicated. Another solution would be to introduce panic_down_trylock() variant of down_trylock() that will use raw_spin_trylock_irqsave(). The normal down_trylock() might still use the raw_spin_lock_irqsave(). Well, this should get discussed with the locking people. Best Regards, Petr