Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1321076pxb; Wed, 30 Mar 2022 00:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzzgDd2OuadGdR9gD/3oScpxryEbo+bJI/zYcfMRtItFDy/vuRM7d8ldqpJxOMmjMTU7YF X-Received: by 2002:a05:6402:51d2:b0:419:7d2e:9d0 with SMTP id r18-20020a05640251d200b004197d2e09d0mr8993620edd.82.1648624392469; Wed, 30 Mar 2022 00:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648624392; cv=none; d=google.com; s=arc-20160816; b=oFozlxp8nTLAjLFBDhVnORR6HRoFKs9aioRnljFdTWJtqP1rren1spYBwIpeJFzY/m aD0VrNeeSg16x7hEEUabqD40C5ym3N9hH7fZrmoCYsKdRONm7M70LEkob9Piw4mhoysI x7onhb9dFGE2miaYMkssa39SpnX/FmKtUQ5e7xckoTBF20WrK5aSMa72NAX/hj+yXXQ7 eqEhAeK2Y0k3mRP2jGvkuGYDr4+pD2ou+ubt3QuIsu6bX8olmADVP6XQOjXnfWcBShsM ipF0Umeg4rQtMZPEom3U6o3UqGbejUPBYwt04WnXa+/Wgwg3w9x/L8A58XDdcuapHxY4 QcWA== 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:dkim-signature :dkim-signature:date; bh=UqR3ZXxf00+8NZqVN4Njt/+BMl84gb+Z44sVz+Vkamw=; b=rrWHiM+kpwytARMCpkI+ejMXwIL6pcfEdv2MikcO2WcNkMZKEICPP2IIUzorvKlV41 nueiHTxVZ/E5eOs9rwhfeWCOQI8OC7e5VxyVh7E4kyQ30KCYe/saigiqyAgXk+nmHqGK QR14hEj3SpVkqWjkGz1qHX3jGBa54ZBU5OVeFqH/yJzegmrTcvMkTt/TmDijHfjafQjW gRck1Hu5AY9NUQcXf7vpvuXRCkneOtC5KzN53za7bqIJMtoR9iBoQM3ikpwhdb3H3KCJ +2VxWEyx1FWzza43JHR65KNnsl4fTrQoGZEaKA00WhreNR9/d0tHNOtSaD7U40V1AIqX qPWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vaMsgaB0; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o13-20020a170906860d00b006dfa8e11aa0si18724247ejx.792.2022.03.30.00.12.46; Wed, 30 Mar 2022 00:13:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vaMsgaB0; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234748AbiC2Jc6 (ORCPT + 99 others); Tue, 29 Mar 2022 05:32:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232590AbiC2Jc4 (ORCPT ); Tue, 29 Mar 2022 05:32:56 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACFF41229B8 for ; Tue, 29 Mar 2022 02:31:14 -0700 (PDT) Date: Tue, 29 Mar 2022 11:31:10 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1648546272; 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=UqR3ZXxf00+8NZqVN4Njt/+BMl84gb+Z44sVz+Vkamw=; b=vaMsgaB0Y8YtyQkqBOYAYOs+wyfO/U13zZioSm0qy+mjCToOS8j7BmU+uSRN7+3P9Czsjv YuZ2dY8Czz3d6P0R6YeUUJ95tBe8bXoZ59W2wuHQCPcytNOI4Ip/q/o1zw/z9b19x9s5S7 YxRurfmiwD8/imfgZxbc42j+u7Z2ly9VgidAi8CUW1fNmUc0mX6MAis5vch/iazHm4xvnQ WJm5hEtG7JfhCXN0wPVb9ej1aP/crNgxPruo8BGat2iBUdO6EbgfNtfqTGJgSu0RRn/8EL xrxBeVQJPiVU9CVRM0Ecf4pgME+fTL9xymMUOYh9qYAFzEwuVoJa3EXu0erOow== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1648546272; 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=UqR3ZXxf00+8NZqVN4Njt/+BMl84gb+Z44sVz+Vkamw=; b=GPDKutsXZZE4DYw1TcWWZz2TaPH8KblS122J75briGmOC6u5obN/qXe2Po5UD8AQrFS9WA 9jL+hgFIwOxQoFCg== From: Sebastian Andrzej Siewior To: "Eric W. Biederman" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov , "H. Peter Anvin" , Andy Lutomirski , Ben Segall , Borislav Petkov , Daniel Bristot de Oliveira , Dave Hansen , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Vincent Guittot Subject: Re: [PATCH] signal/x86: Delay calling signals in atomic Message-ID: References: <8735j2xigt.fsf@email.froward.int.ebiederm.org> <87zgl9pw82.fsf@email.froward.int.ebiederm.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <87zgl9pw82.fsf@email.froward.int.ebiederm.org> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-03-28 17:07:25 [-0500], Eric W. Biederman wrote: > Sebastian Andrzej Siewior writes: > > We have a few other cases where we deliver signals from interrupts. > Off the top of my head there is SAK and magic sysrq, but I think there > are more. So I am also not convinced that all signals you care about > will go through force_sig_info_to_task. > > What I really don't know and this is essentially a PREEMPT_RT question > is what makes int3 special? Why don't other faults have this problem? int3 on x86 is delivered from the debug interrupt and at this point interrupts are in general disabled even on PREEMPT_RT. If you are in a section which disables interrupts via spin_lock_irqsave() then interrupts are not disabled on PREEMPT_RT. If you are in an interrupt handler (as per request_irq(), not the special vector that is used for int3 handling) then interrupts are also not disabled because the interrupt handler is threaded by default. In both cases in_atomic() reports 0 on PREEMPT_RT. So the exception is: - explicit usage of local_irq_{save|disable}, preempt_disable(). - usage of raw_spinlock_t locks. - interrupts vectors which are not threaded (like int3 or the SMP IPI function call). > I remember there was a change where we had threaded interrupt handlers > to get around this for interrupt service routines. I wonder if we need > to do something similar with faults. Have a fast part and a threaded > part that runs in a schedulable way. Although given that for a fault > you need to be fundamentally bound to the task/thread you faulted from > it probably just means having a way to switch to a kernel stack that you > can schedule from, and not use a reserved per cpu stack. The > task_struct would certainly need to stay the same for all of the pieces. > > Or maybe for PREMPT_RT you pick the i386 mechanism. How does PREEMPT_RT > deal with page faults, or general protection faults? An in-kernel stack overflow will panic() with interrupts disabled. An in-kernel NULL-pointer is also entered with disabled interrupts and complains later about sleeping locks in do_exit(). I do remember that the arch code conditionally enabled interrupts based on IRQ-flags on stack. > This is my long winded way of saying that I rather expect that if > PREEMPT_RT is going to call code it has modified to be sleeping that it > would also make it safe for that code to sleep. > > Further (and this is probably my ignorance) I just don't see what makes > any of this specific to just int3. Why aren't other faults affected? That NULL-pointer in kernel doesn't look good. If you have a test-case (like do this) then I can definitely look into it in case more is missed. > Eric Sebastian