Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp14291rdb; Wed, 17 Jan 2024 15:26:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1wvAIuEkgWYZ1cCL6cjMal3IJi0pEFDlz3cTRJ1EHbram8Rn9a2s+QiZJaJ7ZBaI8diuS X-Received: by 2002:a17:902:ee15:b0:1d4:40f3:7ab9 with SMTP id z21-20020a170902ee1500b001d440f37ab9mr2183420plb.40.1705533967167; Wed, 17 Jan 2024 15:26:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705533967; cv=pass; d=google.com; s=arc-20160816; b=VSsEuGY+ZqbdxEdRZysX/M5E5W+VolMopsfliNuBB5Sd+HkRUNmlV6DqLc1MM1z8hU oLVFvQ8ieKBNpYiy/qCZp3nnP3ADaB0VshddHKj2Lqg2go/Ute6WN5jvrRb8fXCLPnsv 9DTXyJqwfu0FVWIU/x1Bsu+pRl52M83gf3u49QuY7BAKn98iT2LjYWwGQEJuxHAlUDC6 +tBaMPNkhUxf/LXbjAVldVExuuFwJezQD1sAkUju3jjvBuMEAH0MPk7oWGQlLORGqu4k w2tIsMoD3naqc/y7zE090O8DhrJmb9vbayZD3pPkDvqD74+sIXbs2CxSvtPzncjenDP8 u50g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=MojhU4GRzsLWYYfrEcAZeXUgW5CKtIhKDn39POD9PAg=; fh=NdLlDrmWWpXBCGDg5f3M8CpQBokHQDiuE7DgGeBQ3l0=; b=lmBafLRQM10gcn1e5dkizLREpQ9CqlmhHnFfgU9Mbx9yMD2oFaWvoaUHicrws2X1WV 7O8G8LZXND//3TGza5O1pbOLCLMhrCRiKDFBNjuxWjidxlrWMUtWV8H2m6MTofW514yw aO+Klm2GF8oy5YvPULOUQxxYWxdkNqKceCf7zIEmwnq1swKuHTXRtV12lZOhgZXalkay Vo3lJsYYC+BuZveRoDpLnz7NjLDf+98MYe+15BFvmBNRCk8ptEKQPxhDtYwRoGEvDNcC 22ZQTjZioDZuWiQdGu7pD8US4OJtxiCAN/HwUQoD2shuk2sb5yFCMRVOnefXDplboRjU EVgA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i66YdexJ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-29548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d22-20020a170902b71600b001d06da42b0csi353549pls.503.2024.01.17.15.26.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 15:26:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-29548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i66YdexJ; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-29548-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-29548-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AC4F7B27861 for ; Wed, 17 Jan 2024 23:19:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1255925639; Wed, 17 Jan 2024 23:19:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i66YdexJ" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 8B9FF21A12 for ; Wed, 17 Jan 2024 23:19:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705533549; cv=none; b=rAAnLw/ZtXUCDHEctET5iLezg+ZdoIPrJpAsAI7g2y2O7wrHOmPyRvx1qc5Ynn5X1u7mmKZArOdBbwZj0EqGDPQySjMYBxM5gXw9deD8C5clUU+1T483np4fOlS2yqCJ+RovHQj3KyvOODK3xJk/Hy+DieKZZRAxO2ZZ9yOmEPI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705533549; c=relaxed/simple; bh=nuk6PFQ9+p+9wuWPs1iRr1kUgHqCggJoF6Qj/g7bbpA=; h=DKIM-Signature:Received:X-MC-Unique:Received: X-Google-DKIM-Signature:X-Gm-Message-State:X-Received: X-Google-Smtp-Source:X-Received:Received:From:To:Cc:Subject:Date: Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Disposition:Content-Transfer-Encoding; b=OFx2/uxmqQWlSW86LyhLlusyW1sGCC4DV0lFmbvOeUrEauSjD6/wOBPJdXU4OnzyLHxNKBQ9UF2C/xU6pz2Qpr50vjNAlAF8RCrFk5xj4OLgTk5jRrbazGmfAOxtQ3iPC3NbyZzO9ADtb0JnCJuof7Dxm5ZvD4GbvQBptg8RVHw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i66YdexJ; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705533546; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MojhU4GRzsLWYYfrEcAZeXUgW5CKtIhKDn39POD9PAg=; b=i66YdexJQSYekf9Vcgl8S9Av18P27rA0wljIMJk10DfjG89+E993Yq9Us7zB38D/VBbBxD R5VWMqv7YWBNy3ezTybopzImzT//qoGD52GLLbM34H+ZbeAedGgEMQhlF+5eqAbBGhkvn4 2ZLmzGFMvMFLHIfjRja8yvK+z+FKDpQ= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-U-J3z6itMWSOq-gNIe3lSw-1; Wed, 17 Jan 2024 18:19:03 -0500 X-MC-Unique: U-J3z6itMWSOq-gNIe3lSw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7816bea8d28so35227285a.0 for ; Wed, 17 Jan 2024 15:19:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705533542; x=1706138342; h=content-transfer-encoding:content-disposition:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MojhU4GRzsLWYYfrEcAZeXUgW5CKtIhKDn39POD9PAg=; b=Q25Z+1Gi/lFlQP/97KfG5kZGNA+uuuPgcj3in7Yry+EQR/wcRBUd/ZLIzusMASmLqE BhMnKG83RK2T8/48fvmeDZmDOxF1tC8sbaE9r4qoxAwwjhjLMS3FFKar30hfothwTQcV Vq4MRLsMcUUn6MSaL5/L80r3ltR7nC5YUsnJZ6o1uliziHYVFPvglAjDze1U2wqalCAq Z0Rvi5vUaFgDW12FODdtr6nFZam//I5hs+JTaOSQnQ8KMvuFICwmuyShqir471MtANmd N2vghhk72IxWryn/+fuXXNdzqn42mBrGBg9oZKhoOunNGzvMty6R/W8zT8lP9yoxQ98D dutA== X-Gm-Message-State: AOJu0Yz6u71HZKWxyeOpjV2szDI3jkLJhPRDK2OhbHTwzl1FUvymxuj5 Fl3a1/oOZMSW/k1JxegDZr6uf20AKJIQS0cl7ng4YKt6Z+xsXHmbVaBGL2AmLqpQDhkNYv/y09V btJoVvSF4KXhzU8eydQZsdHvnMouw6w3YTpa7MvkVFfcoDkiZds6bNY7V9OB6UQ== X-Received: by 2002:a05:620a:379b:b0:783:4d55:f213 with SMTP id pi27-20020a05620a379b00b007834d55f213mr71708qkn.46.1705533542151; Wed, 17 Jan 2024 15:19:02 -0800 (PST) X-Received: by 2002:a05:620a:379b:b0:783:4d55:f213 with SMTP id pi27-20020a05620a379b00b007834d55f213mr71699qkn.46.1705533541923; Wed, 17 Jan 2024 15:19:01 -0800 (PST) Received: from LeoBras.redhat.com ([2804:1b3:a803:6ad1:9baf:f024:858c:2fee]) by smtp.gmail.com with ESMTPSA id d1-20020a37c401000000b00783189b0aeasm4866671qki.46.2024.01.17.15.18.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jan 2024 15:19:01 -0800 (PST) From: Leonardo Bras To: Thomas Gleixner Cc: Leonardo Bras , Greg Kroah-Hartman , Jiri Slaby , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Andy Shevchenko , Florian Fainelli , John Ogness , Tony Lindgren , Marcelo Tosatti , 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 Date: Wed, 17 Jan 2024 20:18:54 -0300 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: <87r0ifful4.ffs@tglx> References: <20240116073701.2356171-1-leobras@redhat.com> <20240116073701.2356171-3-leobras@redhat.com> <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; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: 8bit On Wed, Jan 17, 2024 at 11:44:55PM +0100, Thomas Gleixner wrote: > 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 agree, but the alternative was to have a BUG() due to scheduling in atomic context. This would only ignore the lock if it was already taken anyway. That being said, I agree it is not the best solution for the issue, and just sent this in the RFC in order to get feedback on what could be done. > > I assume that this is not against the latest RT kernel as that should > not have that problem at all. I am based on torvalds/linux at master branch, so maybe I am missing some RT-specific patches. Which tree do you recommend me testing? > > Thanks, > > tglx > Thank you! Leo