From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2A207EB64D7 for ; Wed, 21 Jun 2023 13:08:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 892B88D0005; Wed, 21 Jun 2023 09:08:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 81A8B8D0003; Wed, 21 Jun 2023 09:08:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6BBCE8D0005; Wed, 21 Jun 2023 09:08:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5CECF8D0003 for ; Wed, 21 Jun 2023 09:08:33 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 073578075C for ; Wed, 21 Jun 2023 13:08:33 +0000 (UTC) X-FDA: 80926784106.07.0A06924 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by imf01.hostedemail.com (Postfix) with ESMTP id 60EA040224 for ; Wed, 21 Jun 2023 13:06:46 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=zFzfwKyd; dkim=pass header.d=linutronix.de header.s=2020e header.b=ypaKY+jh; spf=pass (imf01.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687352806; a=rsa-sha256; cv=none; b=BYUUBQpJ7ZYKITzdXa4WukrYNCV9zc2qYtKlUUwmUiS2R1fDQ9osHZO6UehH16I+etS1w+ MCbw5eJ92zNq/Z1zPx3LnZWYQGYZVelds5TdUzYsp15Xa4ymFgTq+5wZo9c6f0vF83H6MS Jv1kLb4N1lIE2PEffv53xcH39ZT0Jlk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=linutronix.de header.s=2020 header.b=zFzfwKyd; dkim=pass header.d=linutronix.de header.s=2020e header.b=ypaKY+jh; spf=pass (imf01.hostedemail.com: domain of bigeasy@linutronix.de designates 193.142.43.55 as permitted sender) smtp.mailfrom=bigeasy@linutronix.de; dmarc=pass (policy=none) header.from=linutronix.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687352806; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EiTrt1RxkiVtMrEXWH8nU0B562FLZwF6+3X/J6J6DVA=; b=8dTG+IDQSSISGWKYQnv2boqpd0oPfB1GEUAfpSMl89i2sa0hgmmyJ7w8lcNao5jgVM2iLo LHLfEKH6V1wC3xeKCgh7xAlBl1ffMDj96YHi8MGiC9RfGy61/5b5rYawJlKqHxUAlZ6cAC hV6MPUND5/pvrZ85Gy8AzVtiEaneZXY= Date: Wed, 21 Jun 2023 15:06:41 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687352804; 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=EiTrt1RxkiVtMrEXWH8nU0B562FLZwF6+3X/J6J6DVA=; b=zFzfwKydm/aTHwMWQiwwAEkVWvoGDr66isIlUVKutfp1hFm7wYxam+v9S/F13j84cvoMyb KQtmJ9mocdt3/mSbpKDPe0XSvP9PBVwDAZqnpUYYvRIRRV7toKL83JIJczWIceZMNx9hDR cUbQpsOdKDWvMf+HOHy7F9W9IBhG+6xR4LcJdbtJM4vBuc+ktkNNfSRwNhV56PhMKTVBKP HltekMecsWRKfF4YhlBT0zCTXPuY0g8vRMbuoMrer+qU0+5P7ILugJXaWcSwz4MHAWdaMA C7ykBe7VZOOP3mqAyP3HzW2SbGeoXgLk58YrYI2ZeuDclcPIhP9Rm+IQSVGr6Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687352804; 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=EiTrt1RxkiVtMrEXWH8nU0B562FLZwF6+3X/J6J6DVA=; b=ypaKY+jh6n7szkkKGRT4XdbZ/zEap+da1HKGQTkBlu6f3RX8Yj79vqAMZQD18WbQWQsbrk c/6VT3/W1IgLiGBg== From: Sebastian Andrzej Siewior To: Tetsuo Handa Cc: linux-mm@kvack.org, "Luis Claudio R. Goncalves" , Andrew Morton , Mel Gorman , Michal Hocko , Thomas Gleixner , Petr Mladek Subject: Re: [PATCH] mm/page_alloc: Use write_seqlock_irqsave() instead write_seqlock() + local_irq_save(). Message-ID: <20230621130641.-5iueY1I@linutronix.de> References: <20230621104034.HT6QnNkQ@linutronix.de> <0e9fc992-8e05-2e63-b3b1-d8d3ce89fc16@I-love.SAKURA.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <0e9fc992-8e05-2e63-b3b1-d8d3ce89fc16@I-love.SAKURA.ne.jp> X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 60EA040224 X-Stat-Signature: zngn9xq87new4mzfgj1rj4pe38ygs5mi X-Rspam-User: X-HE-Tag: 1687352806-901995 X-HE-Meta: U2FsdGVkX1+JJsxt3z2bzjwh5WXLI6eCgWYLtE6B06EZB78WteF25o+k8RiJRMJCryJMJsIJqGOBwKH1B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=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2023-06-21 20:33:35 [+0900], Tetsuo Handa wrote: > On 2023/06/21 19:40, Sebastian Andrzej Siewior wrote: > > printk_deferred_enter() has to be invoked in non-migrate-able context to > > ensure that deferred printing is enabled and disabled on the same CPU. > > I can't catch. local_irq_save(flags); makes non-migrate-able context > because sleeping is not allowed while IRQ is disabled, doesn't it? That is correct. The problem is the local_irq_save() which remains on PREEMPT_RT and this is problematic during write_seqlock() which acquires spinlock_t which becomes a sleeping lock. write_seqlock_irqsave() substitutes everything properly so on RT there is no local_irq_save(). > > This is the case after zonelist_update_seq has been acquired. > > > > Acquire zonelist_update_seq with write_seqlock_irqsave() and then defer > > printk output. > > What guarantees that write_seqlock_irqsave() never calls printk() > (e.g. lockdep warning) before printk_deferred_enter() takes effect? Actually nothing but this could fixed by making the lockdep annotation first followed by the actual increment in do_write_seqcount_begin_nested(). I don't know this is the other way around since we do annotation followed by locking in order to see the splat before it happens. Let me do a patch for that since it looks like the right thing to do. If this "rare" issue is a blocker I don't see a sane way around it. Be aware that tty_insert_flip_string_and_push_buffer() has atomic/ KASAN annotation which _could_ detect something which then leads to pr_err() invocations while tty_port::lock is acquired. Looking over tty_port_close_start() there are pr_warn() invocation with the lock held so again, possibilities. Petr, is printing via print threads and direct printing via explicit driver callback (which would avoid this problem) on the agenda? Sebastian