Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4141427pxu; Mon, 12 Oct 2020 10:30:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAqxFmVdp8Ob1jUuBRkrEkmPxHWnh5KJW+v585lb20sMI+0KMcCUDVHRxAmAIAKgHSly4U X-Received: by 2002:a17:906:1e04:: with SMTP id g4mr2431031ejj.72.1602523826939; Mon, 12 Oct 2020 10:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602523826; cv=none; d=google.com; s=arc-20160816; b=w7rDXnBajxxkUarOPY0VLhfpY4miDVgD7KTtn3Nb0gI0S/5dn6q4yLAfwH3Vdjc7nm ex+2YOhXkyHanm9EYE6pN+98xlgBwG+zp8meFhY+NRWNgTChSOo8KXAL4VPWOSVRz3Gy wrdlumaZ6oL0cslRuBN7F5KReJd1GKD1LemQm1WZKNgKp9dvoFnvKBRt1lhPq7LcbQ/Q 4XZ42LfWB4+sogDYlQwGWS14bfjStqige0aqfVDzkd8mcz4kKbW3dGG4v4HaJx/dn+VE UPoiN7Zp0P0dg1x5d2McYFlo8y9xG9ci9SvFRcS4SXMNpI0jz9s33uCbWv0CaWXrfipM Z36Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=I3zg99vBXcuh34PvVBTAkpqN4TVDoyo/f48ezLKI/jw=; b=H2xCeteWhtPWd0XMT5qhYp36kKYxe2N2BYlQDu6ls+VmOvezf5ZBIWXLqMP/w15OOP VTddkRd/34FFDZ6AIc+woszqlG+DvKXRzvf2BgbDlK6cCfNrP1tKFMoO8r0QiB0KayZ0 YGvG/TPBz0HwZbxJ34wm7JuqeNtawDsl6KXy0LM5siVn9PTmIzDim/cdXChsb2zyz2OU o3AXHFFSg2VrF3L65rt6r5nS6lrLSBNA8jhTdrF0hY0uCzL7dm0HqngJXAH8a8Ndcseg tFQa3iGxJptrxajxQHtUIVMwjieSgrC/KTemUi3OT4yFFkmSD8dRDFh3BxifzZ0f5yPM deLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j24si12318508ejb.48.2020.10.12.10.30.03; Mon, 12 Oct 2020 10:30:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404054AbgJLR1v (ORCPT + 99 others); Mon, 12 Oct 2020 13:27:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:40582 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390753AbgJLR1u (ORCPT ); Mon, 12 Oct 2020 13:27:50 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 458A6AC6C; Mon, 12 Oct 2020 17:27:49 +0000 (UTC) Date: Mon, 12 Oct 2020 19:27:48 +0200 (CEST) From: Miroslav Benes To: Jens Axboe cc: Oleg Nesterov , linux-kernel@vger.kernel.org, io-uring@vger.kernel.org, peterz@infradead.org, tglx@linutronix.de, live-patching@vger.kernel.org Subject: Re: [PATCHSET RFC v3 0/6] Add support for TIF_NOTIFY_SIGNAL In-Reply-To: <9a01ab10-3140-3fa6-0fcf-07d3179973f2@kernel.dk> Message-ID: References: <20201005150438.6628-1-axboe@kernel.dk> <20201008145610.GK9995@redhat.com> <9a01ab10-3140-3fa6-0fcf-07d3179973f2@kernel.dk> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 10 Oct 2020, Jens Axboe wrote: > On 10/9/20 9:21 AM, Jens Axboe wrote: > > On 10/9/20 2:01 AM, Miroslav Benes wrote: > >> On Thu, 8 Oct 2020, Oleg Nesterov wrote: > >> > >>> On 10/05, Jens Axboe wrote: > >>>> > >>>> Hi, > >>>> > >>>> The goal is this patch series is to decouple TWA_SIGNAL based task_work > >>>> from real signals and signal delivery. > >>> > >>> I think TIF_NOTIFY_SIGNAL can have more users. Say, we can move > >>> try_to_freeze() from get_signal() to tracehook_notify_signal(), kill > >>> fake_signal_wake_up(), and remove freezing() from recalc_sigpending(). > >>> > >>> Probably the same for TIF_PATCH_PENDING, klp_send_signals() can use > >>> set_notify_signal() rather than signal_wake_up(). > >> > >> Yes, that was my impression from the patch set too, when I accidentally > >> noticed it. > >> > >> Jens, could you CC our live patching ML when you submit v4, please? It > >> would be a nice cleanup. > > > > Definitely, though it'd be v5 at this point. But we really need to get > > all archs supporting TIF_NOTIFY_SIGNAL first. Once we have that, there's > > a whole slew of cleanups that'll fall out naturally: > > > > - Removal of JOBCTL_TASK_WORK > > - Removal of special path for TWA_SIGNAL in task_work > > - TIF_PATCH_PENDING can be converted and then removed > > - try_to_freeze() cleanup that Oleg mentioned > > > > And probably more I'm not thinking of right now :-) > > Here's the current series, I took a stab at converting all archs to > support TIF_NOTIFY_SIGNAL so we have a base to build on top of. Most > of them were straight forward, but I need someone to fixup powerpc, > verify arm and s390. > > But it's a decent start I think, and means that we can drop various > bits as is done at the end of the series. I could swap things around > a bit and avoid having the intermediate step, but I envision that > getting this in all archs will take a bit longer than just signing off > on the generic/x86 bits. So probably best to keep the series as it is > for now, and work on getting the arch bits verified/fixed/tested. > > https://git.kernel.dk/cgit/linux-block/log/?h=tif-task_work Thanks, Jens. Crude diff for live patching on top of the series is below. Tested only on x86_64, but it passes the tests without an issue. Miroslav --- diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index f6310f848f34..3a4beb9395c4 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -9,6 +9,7 @@ #include #include +#include #include "core.h" #include "patch.h" #include "transition.h" @@ -369,9 +370,7 @@ static void klp_send_signals(void) * Send fake signal to all non-kthread tasks which are * still not migrated. */ - spin_lock_irq(&task->sighand->siglock); - signal_wake_up(task, 0); - spin_unlock_irq(&task->sighand->siglock); + set_notify_signal(task); } } read_unlock(&tasklist_lock); diff --git a/kernel/signal.c b/kernel/signal.c index a15c584a0455..b7cf4eda8611 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -181,8 +181,7 @@ void recalc_sigpending_and_wake(struct task_struct *t) void recalc_sigpending(void) { - if (!recalc_sigpending_tsk(current) && !freezing(current) && - !klp_patch_pending(current)) + if (!recalc_sigpending_tsk(current) && !freezing(current)) clear_thread_flag(TIF_SIGPENDING); }