Received: by 10.223.164.221 with SMTP id h29csp956585wrb; Wed, 1 Nov 2017 08:08:32 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Q2l6EuizLqnYAb/02lrG3MXJpmCRs6Kf2HW6yWPECwY9APXj41tHhej68x7e0xy6U3U4hy X-Received: by 10.99.3.1 with SMTP id 1mr184554pgd.111.1509548912688; Wed, 01 Nov 2017 08:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509548912; cv=none; d=google.com; s=arc-20160816; b=FIhaebn8xp7IPsFTJ/rucQrfafmKb++YZxsOawWr64z2VhZCxFerEulcKP6eUDhJ0t Vse4s65CGzf+94/xXmGyJSj0anIXTZU23/Rz/myMldndC66z2cZbLVRkQNOjYCVTU6Fs c5FuMnaIrx+7B4V8TKLOK09OyS/B/0jmrzo55YEWyIHXPP04L8XeLIi1Cwv70wqXiZAR lR4bU9PWpW3m+J8U1COr4SUHi2IPwUnW6jMAuX7nXnF030bNkq6m0Hi6xZ7s3BR/PcT5 KDMjDDPVgeHgY23rLQRMDnDRRRwyyApCsa+Dt7aTXrI1oAPceVc5qCznXLU7suS6qcA3 g8SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=h2y1ncJYJvjtx+7JpFYtIw3x6T8HsTx43dT9+D2rhUA=; b=pst2DAAfJ4tcSkxEffRsCghyOm5uxQFT5KrFZVYK8gOmKJw/B6MRmJlMmD46NNQMMR uP0UDiGv/epf0RzPdVX2sYHZph1XDtsG/ZpUdt1N6nOUG/mjIccvzMg9uMMiT+SarFNm UuwAxlqpDSq0IEK6GgySgAiyc+O2xBXpfrKCYYjoKrS6HSJn21nnXqZmckUN9OGsytf1 0RbCvDSTEz8FnNxgZyOOlinR37BB1XUhhJZhnasN0nBZLlJX1OOiYU5ha4YKzcMHctdP TqPBL7mvsqGK3MLpWPmbP+IwVlPgVa4gxE/ohnh7tww2LILqv6xKc99IPnZooG7UzhdZ Dlsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k18si1341736pgn.129.2017.11.01.08.08.18; Wed, 01 Nov 2017 08:08:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752435AbdKAPGY (ORCPT + 99 others); Wed, 1 Nov 2017 11:06:24 -0400 Received: from mx2.suse.de ([195.135.220.15]:39490 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750848AbdKAPGX (ORCPT ); Wed, 1 Nov 2017 11:06:23 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 39BB3ACF0; Wed, 1 Nov 2017 15:06:20 +0000 (UTC) Date: Wed, 1 Nov 2017 16:06:19 +0100 (CET) From: Miroslav Benes To: jpoimboe@redhat.com, jeyu@kernel.org, jikos@kernel.org cc: pmladek@suse.com, lpechacek@suse.cz, pavel@ucw.cz, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Oleg Nesterov , Michael Ellerman , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Andy Lutomirski , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH v3 1/2] livepatch: send a fake signal to all blocking tasks In-Reply-To: <20171031114853.841-2-mbenes@suse.cz> Message-ID: References: <20171031114853.841-1-mbenes@suse.cz> <20171031114853.841-2-mbenes@suse.cz> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +/* > + * Sends a fake signal to all non-kthread tasks with TIF_PATCH_PENDING set. > + * Kthreads with TIF_PATCH_PENDING set are woken up. Only admin can request this > + * action currently. > + */ > +void klp_force_signals(void) > +{ > + struct task_struct *g, *task; > + > + pr_notice("signaling remaining tasks\n"); > + > + read_lock(&tasklist_lock); > + for_each_process_thread(g, task) { > + if (!klp_patch_pending(task)) > + continue; > + > + /* > + * There is a small race here. We could see TIF_PATCH_PENDING > + * set and decide to wake up a kthread or send a fake signal. > + * Meanwhile the task could migrate itself and the action > + * would be meaningless. It is not serious though. > + */ > + if (task->flags & PF_KTHREAD) { > + /* > + * Wake up a kthread which still has not been migrated. > + */ > + wake_up_process(task); So this is not as safe as one would hope. It tries to wake all TASK_NORMAL tasks, which could cause headaches. Let's make it wake_up_state(task, TASK_INTERRUPTIBLE); to wake only kthreads sleeping interruptedly. Thanks Petr for spotting this (offline). Miroslav > + } else { > + /* > + * 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); > + } > + } > + read_unlock(&tasklist_lock); > +} From 1582773844473281428@xxx Tue Oct 31 11:52:44 +0000 2017 X-GM-THRID: 1582773844473281428 X-Gmail-Labels: Inbox,Category Forums