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 9208FC6FD18 for ; Wed, 19 Apr 2023 12:14:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19A958E0003; Wed, 19 Apr 2023 08:14:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14AD48E0001; Wed, 19 Apr 2023 08:14:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 038EE8E0003; Wed, 19 Apr 2023 08:14:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E89F68E0001 for ; Wed, 19 Apr 2023 08:14:19 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A58FA1A01A4 for ; Wed, 19 Apr 2023 12:14:19 +0000 (UTC) X-FDA: 80698033038.22.310C8C0 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf25.hostedemail.com (Postfix) with ESMTP id B8994A000E for ; Wed, 19 Apr 2023 12:14:17 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=j1vKSRL4; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681906458; 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=P75V+PHCMLRraJ75ssd9S6FUz/in7e36rjP7Uvyk1M0=; b=51NOVQIm8v9ZCWOhacr25vNJU3/LmPkBzdZ48xOnZVwdB/xcCydgtaatAPBrLLdWNaEz76 njMrNYaef+LD6/0VyM5uf0SedcAHIu3hJROfQDgOckitjiqo9icLeY9b9aMI3Cwexl5PQ4 mbFrJkH1QzTW5Fo64PZ8fcmLz8HqPLI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=j1vKSRL4; spf=pass (imf25.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681906458; a=rsa-sha256; cv=none; b=K66gMrpXP7BzmrEYRg9E+idu8fldbY1jQZxP3ACLSYiToTinxSxIiSHPHGTLqcqZ4gqwPc wMMexQP7q4/w3v2HaaCRzLJnN9LVEkWtIz0Nthyc6mGOHOOpOgrozjHWMwOHo1FDnc+ybU jxpvt6XDWlOxWeAeB47GdDq3fPrro+0= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6E6C81FD8B; Wed, 19 Apr 2023 12:14:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1681906456; 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=P75V+PHCMLRraJ75ssd9S6FUz/in7e36rjP7Uvyk1M0=; b=j1vKSRL4ILQL3REI4O2rzaEGsUxK5VAzhbkZMe3cXH2+EiMZ4JD0to7agaVvNPf4xX1GTt nWeh3DqzBRugu0RerHtiSW3a+mPmyaeEKf9k5EucFhUfLp93K5jdYJbBpTIUiga3yt9D6X 0o3/vQsH2C7yJkgzXUE3PSX68xpt7bA= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5283C13580; Wed, 19 Apr 2023 12:14:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 86TOERjbP2S8fwAAMHmgww (envelope-from ); Wed, 19 Apr 2023 12:14:16 +0000 Date: Wed, 19 Apr 2023 14:14:15 +0200 From: Michal Hocko To: Petr Mladek Cc: John Ogness , Sergey Senozhatsky , Steven Rostedt , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] printk: Enough to disable preemption in printk deferred context Message-ID: References: <20230419074210.17646-1-pmladek@suse.com> <87r0sg5jin.fsf@jogness.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B8994A000E X-Rspam-User: X-Stat-Signature: h41faqkhax3iey747bojy9fbkth4pse4 X-HE-Tag: 1681906457-128783 X-HE-Meta: U2FsdGVkX19NppxBfefSZmhfmgDh/tiaZxDzuxZU/PovoVlLsEeIlMJHXsZZ008N64cfmFsNBc+f82xE5u1h4+LVvSy3SmANiFPkyP21/uEZA2mmhQVgzvBFDZ3yZX4NR+6r4MtvzxQEuFtgyAG7n/eo1H0pte7DyW8vp3rTk8szfF2UUcuUaCRfNjXn9jwix1AwojCIQ4Pt67Ubil0muhpesuX8gXOVNyz1iUg9PY1oFhVxAce/gzUMpt0G3qVdUdv81dM/jNIe+3iG2hjaaV/uSUjXm8X4GJPeMZhcsM5IFXqCuQ4mVYWWEfOJ+YxQurGRggJqdkexUbT5zzA9VzfVDHYQHBDSTbcgTnDgVGxsCRcZiFunEJluNVtADsrQI8fEwaZGBotjnnoMhG7NBv1G41V5uU55ELgELVvgwLEvs1O+SJDPIR8wu7fpcfIVcn3J/gs5H9ZX1/x43gOyMQCk8FQjWKPaIBmVOKNpj9NpXm3ZKYVM+Br1IzyAaJZjoWAzZjaQ8REuHXn3sAZ1RUpV/Ea4L5qctpg73464dYYh+9lUCbL+H3hA+HMhcGZvDktu7KsFzxqJIssjsxc+PxdaLQAq7odzzTfptPwb4Xn3HKwKdK4NP+7J6zN5vAkEPfAPW58FiC0MFPslzeZvdDpzLMqnTugtigmFhItDG+3VVGuQNrswRyyoXqWO/k79cTv9NURjAcq1oyU9VIjgeWgChxfOw2A+0mupPZ/10eVkXKvNjCGRKrMJCAt4WT20t0yl+N6eZ/jzG+1sXKcRDJiLgTJs/tn2V7bxNT/QMTTfmuIYnXqE0zwqrXTKS5Q6kE+xIE1G9E+AWwOTa64RM8kq1QEWxHJFfHNWsEWtn9ZvRbLIhM+a3BDdTjngEAKT5upTy7pWNH7yMyzZH+KzUHCURWaw18QTA7YJ2d10nKe96C8c/n+vk9XsO0prDsmXSjUZVIXv0/wdfkaAiUZ 3xuTepi8 OtTDFhQ9BPIjJcbcFHOCxacQPqimMIlqZAB24ZYhG4hr1/nmvAPtYOKimZLVAPFxgxQfxKz91ExQJhtzhB+MKmMNxqxondoanJFNt+hSa2M885/dLwvuftXHS0qsRj5Aae/mZxJGI6VxZfTJ237vjYwfJnQQzCOkbQXO7cvutMAVgGdlrx7gx+QtrKTt2MH7JYXggdqPp6SUFxqINCiiC8kJab9/EAjOqJxwK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed 19-04-23 14:03:29, Petr Mladek wrote: > On Wed 2023-04-19 11:11:52, John Ogness wrote: > > On 2023-04-19, Petr Mladek wrote: > > > it is safe to interrupt one writer now. The preemption still > > > has to be disabled because the deferred context is CPU specific. > > > > Really it is enough to disable migration. > > True. But it gets too far to my taste. As you describe below. > It affects all printk's on the CPU. > > Sigh, even the enabled intrrupts might be questionable. For example, > when the iterrupt is from a watchdog and want's to report a stall. > > > We need to keep an eye on the usage of this function. By allowing > > interrupts and preemption, it means that other printk's on that CPU will > > also be deferred if the context interrupted within the deferred block. > > A solution would be to make this more clear in the comment. > Something like: > > /* > * The printk_deferred_enter/exit macros are available only as a hack. > * They define a per-CPU context where all printk console printing is > * deferred because it might cause a deadlock otherwise. > * > * The API user is responsible for calling the corresponding enter/exit > * pair on the same CPU. It is highly recommended to use them only in > * a context with interrupts disabled. Otherwise, other unrelated > * printk() calls might be deferred when they interrupt/preempt > * the deferred code section. > */ This looks better but I would argue that as a potential user of those I would appreciate less internal implementation details and more instructions on how/when to use it. What about something like this? /* * The printk_deferred_enter/exit macros are available only as a hack * for code paths which are prone to printk related deadlocks. That * might be caused by locking context around printk which can be reused * directly or indirectly by lower level printk infrastructure. * * Any new use of these MUST be consulted with printk maintainers as the * use might have some unexpected side effects on the printk * infrastructure. * * enter/exit pair must be called from the same CPU without any * preemption in between. */ -- Michal Hocko SUSE Labs