Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp693896rdb; Wed, 17 Jan 2024 14:45:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXT9LCd3kL3+TjbRZX7iIgDDWuYGbVxTMKM2SR26DmH+uigMdNoZUXcSI8btaPXvzMBzTP X-Received: by 2002:a17:903:2986:b0:1d6:f3be:aad0 with SMTP id lm6-20020a170903298600b001d6f3beaad0mr1711401plb.32.1705531506063; Wed, 17 Jan 2024 14:45:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705531506; cv=pass; d=google.com; s=arc-20160816; b=zDifr9roqknpYt/tyL4gbRcj/nKie2ymv/uMNWBr2tBDwFC5X3r0y2ZmBU/ZJPP8od DYb2dCpmDQDgdrgTqyLGJiARy1VdB4vxUIsuYB8cT8cUKgrkNShYzdJVHJ7cv2jW6SA6 XWwFupgdMn6mbK1heVCvPMUoZiAs0F4wolUiM+g3z0Rs7qi9yk5C6SJEo8GTms15BITe yDJL7D6nv12AdJ5jgENlcuLcHdWRJZxE5lZiCYuMHIatmBqD//YCM+Oz6am+koeoTmZT mp7ZDfqxHJto0GLjym+7fIfxC02V6wNYfU8Vtf7Gd+iLKTUcE8w1Nn5mv9I401vUF3BS JI3A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=qr3kH6h7RIJ2sdicFOor/RpNslyEnHGVdaaflfshLS8=; fh=g5nXojL/YFs0IRhYE4wHirFf8J47V18dGluAROxfsFQ=; b=eZjbjxQUqPGhxM2xmt1U30x4WI1QB3ymPlrgQq2zO3X9BlPMcFezfkCHJ6SOqOojF0 3kwp6L3BWZuGXMcXwp/zfGI0MfI3qKC9o0wRjn223hQRMb+RWBBcV6DPSBX7tzGhLXfB fTIGNyREfzZ4n/x1lXiWPCTQsoHjQOcOIVg7EWEbEzl/0/DEwDwH15l+7Xou0YCyAV6K u/fhzAqkvdi/4tKGI4cqoukJ7SKW9KePLyF1y3vA27u7+FLBuc7ppOMisLHWH0UdYYSz 0agN/Xu92vHk6qxFbY3QWGQ6eJjmxGET6vhreCOzZCeL4yM1dUZOD6gYOuCNUYPzO9GJ WCAw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=q5Nbd6aX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-29511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jc5-20020a17090325c500b001d3a67ed545si334181plb.84.2024.01.17.14.45.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 14:45:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=q5Nbd6aX; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-29511-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29511-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B609C281C8A for ; Wed, 17 Jan 2024 22:45:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6A821E889; Wed, 17 Jan 2024 22:44:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="q5Nbd6aX"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ZlD9+QEh" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A96BF1E876; Wed, 17 Jan 2024 22:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705531499; cv=none; b=JYEwBP6QeqUmIUjxoK144hYihFcHWt+7pnODgwWmGX+/KSzVsBckswgF294OpFaU2qp5hX1VhCbTy+ye/X94ZCqV4XThqe8SLxDM0+9f8F1Q1CsUHBeN4OuTsAhoN4UlHaiISFqsNYGSNQvRgpcC20W04UfQJVy5Ymqap1A6p5k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705531499; c=relaxed/simple; bh=uo9ksenHf0PRrhzd7uNRhqtbQ/m5PRRiiMD8IzDJaPY=; h=From:DKIM-Signature:DKIM-Signature:To:Cc:Subject:In-Reply-To: References:Date:Message-ID:MIME-Version:Content-Type; b=tgyHj9nn10FZk7Py2E5QvtN7l8JU6SVTioJXhOazkjpQ+bjHEExWSJIwnDBzG64meKRsipI68d5EuhSwPTGdVCrXKbbfMbnvWXN7v27GOTEx5lm/amEJ3yWA2f2eekMk/H3P19JGfotNpCfeO36FEAyl/hGyxnDilun2G3acwis= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=q5Nbd6aX; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ZlD9+QEh; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705531495; 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=qr3kH6h7RIJ2sdicFOor/RpNslyEnHGVdaaflfshLS8=; b=q5Nbd6aXGzNzRvYJi6G7PYohHTJzIRgJt6fVzRGuL/rAN9XneZSTUHLlGnQoHO+3kY1ke/ V1zNuXWAGM1F84yMFkNT5s/I9PPtt4Mttgl+x9B/T6fF9aIFbDuejchtEsjrVNCm0PRXI3 ebmQkASPnedXVAQSF/UQa5PP8N6xy5mzum5wrqVoBGnGjGVZ9dDQ1I24MLNPqIar0yEmjg BSTcORcrhXFtj8o/+f00oyXJ2r/+PSgnhvFbeXFQAoE+YKw9UD8rAchbUqLX6HyaZzqF4w hKKh4RT17T2wW+uQ7PNv2AmKvIxeikysPfbelvVxnX1q3vKWYJRSiUsHL0Mdzg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705531495; 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=qr3kH6h7RIJ2sdicFOor/RpNslyEnHGVdaaflfshLS8=; b=ZlD9+QEhrSRD/um4Jdb5QhlmKaLo5cGlqQrsKtY+JOc2OZ2gIt6jQGqv7ylLRv0svjwOSo AYF5s5H0mv2K4QDw== To: Leonardo Bras , Greg Kroah-Hartman , Jiri Slaby , Ilpo =?utf-8?Q?J=C3=A4rvinen?= , Andy Shevchenko , Florian Fainelli , John Ogness , Tony Lindgren , Marcelo Tosatti Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Sebastian Andrzej Siewior Subject: Re: [RESEND RFC PATCH v1 2/2] serial/8250: Avoid getting lock in RT atomic context In-Reply-To: <20240116073701.2356171-3-leobras@redhat.com> References: <20240116073701.2356171-1-leobras@redhat.com> <20240116073701.2356171-3-leobras@redhat.com> Date: Wed, 17 Jan 2024 23:44:55 +0100 Message-ID: <87r0ifful4.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, Jan 16 2024 at 04:37, Leonardo Bras wrote: > With PREEMPT_RT enabled, a spin_lock_irqsave() becomes a possibly sleeping > spin_lock(), without preempt_disable() or irq_disable(). > > This allows a task T1 to get preempted or interrupted while holding the > port->lock. If the preempting task T2 need the lock, spin_lock() code > will schedule T1 back until it finishes using the lock, and then go back to > T2. > > There is an issue if a T1 holding port->lock is interrupted by an > IRQ, and this IRQ handler needs to get port->lock for writting (printk): > spin_lock() code will try to reschedule the interrupt handler, which is in > atomic context, causing a BUG() for trying to reschedule/sleep in atomic > context. > > So for the case (PREEMPT_RT && in_atomic()) try to get the lock, and if it > fails proceed anyway, just like it's done in oops_in_progress case. That's just blantantly wrong. The locks are really only to be ignored for the oops case, but not for regular printk. I assume that this is not against the latest RT kernel as that should not have that problem at all. Thanks, tglx