Received: by 10.223.164.202 with SMTP id h10csp3974566wrb; Mon, 20 Nov 2017 07:58:12 -0800 (PST) X-Google-Smtp-Source: AGs4zMZqEqwW6DqSlTg4rWV292ejd5Kj9rXpNw2YJn3nZI3187iX+wfYAqnydH15U9rizxdBFTjp X-Received: by 10.98.197.68 with SMTP id j65mr12032988pfg.176.1511193492253; Mon, 20 Nov 2017 07:58:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511193492; cv=none; d=google.com; s=arc-20160816; b=VM94H5gcXYGMyq4Zll8rPO95IhcGOc+FLg7yvaC6SSty7GIno6/iK6zXn7q18Mk5Wd muXTkRkaHvXOWsdixx6K5s9Xq+9dnSQvAzyepkbixIPUX26yqxmrKBfHpDpKCMc7HVaX eQ+SMdujkRKpw1/kvYf4Qh4uJb4UGpI4cDqFE+M6Tqr+NGXB3KngSwB+FXv7j5wePLVW DcJfnsWmzfzZFgQEaPTRj+6PA8R3VCaGuLh4uvlz0fIyy0hgGwkWbFzNtM7Y8ezd57Iz zyTt2k95kgqn7R9tM/JkOr96ABKn2EL6JoL66wS8QjSRwwT1aChIUeoa2lvzbGeXsB6U 07Zg== 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=OMlxKIPr19LcwFNDGHSjaLDK6jWmwj524r4lO4MWNWk=; b=AwDLqRqAGlzVWMD3W2GFklSmWevrtLP0dYR1aiYaL2f6JqtzYjKh6v+AYL22uquG74 PuBTbGe7LFS6p+/A7sDju1W0YxA2SoVtZWFckk0EO4T5YKh59+wJYzwY+bsIzN/k57OQ WMHWKFSW2Q2QS7Z58rzlbO7O0z/0w5Ghc9wIC1gXG/WymulvuX+UJVInI8guoetL2hZC kx/L3B1RFNhnCRHShUS9mo8X/BflBE7HRyOAxNu+oA8GnhfUh8s2He51sSkK+vl9GREz ++qjQIx6Hn///gP8hpgV+GXPXhjgZYYCg0pBXEbumE/RvR73uROn4wgNZQSX5M2PsrrY 0ANg== 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 k185si8478082pge.131.2017.11.20.07.58.02; Mon, 20 Nov 2017 07:58:12 -0800 (PST) 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 S1751500AbdKTP5W (ORCPT + 66 others); Mon, 20 Nov 2017 10:57:22 -0500 Received: from mx2.suse.de ([195.135.220.15]:43953 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751301AbdKTP5V (ORCPT ); Mon, 20 Nov 2017 10:57:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E73C8AAC1; Mon, 20 Nov 2017 15:57:19 +0000 (UTC) Date: Mon, 20 Nov 2017 16:57: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 Subject: Re: [PATCH v4 2/2] livepatch: force transition to finish In-Reply-To: <20171115135014.20594-3-mbenes@suse.cz> Message-ID: References: <20171115135014.20594-1-mbenes@suse.cz> <20171115135014.20594-3-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 On Wed, 15 Nov 2017, Miroslav Benes wrote: > If a task sleeps in a set of patched functions uninterruptedly, it could > block the whole transition indefinitely. Thus it may be useful to clear > its TIF_PATCH_PENDING to allow the process to finish. > > Admin can do that now by writing to force sysfs attribute in livepatch > sysfs directory. TIF_PATCH_PENDING is then cleared for all tasks and the > transition can finish successfully. > > Important note! Administrator should not use this feature without a > clearance from a patch distributor. It must be checked that by doing so > the consistency model guarantees are not violated. > > Signed-off-by: Miroslav Benes While working on "immediate" removal, I realized we had the similar problem here with modules removal. There is no way out of the rabbit hole. If a patch is forced, we obviously cannot say there is no task sleeping in the old code. This could be disastrous if such old module is then removed (either we disabled it and we want to rmmod it, or there is a new "atomic replace" patch and we want to remove the old one). We need something like the following (at least as a starting point) diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c index 566ab210853f..df4f2bbd9731 100644 --- a/kernel/livepatch/transition.c +++ b/kernel/livepatch/transition.c @@ -33,6 +33,8 @@ struct klp_patch *klp_transition_patch; static int klp_target_state = KLP_UNDEFINED; +static bool klp_forced = false; + /* * This work can be performed periodically to finish patching or unpatching any * "straggler" tasks which failed to transition in the first attempt. @@ -109,7 +111,7 @@ static void klp_complete_transition(void) } } - if (klp_target_state == KLP_UNPATCHED && !immediate_func) + if (klp_target_state == KLP_UNPATCHED && !klp_forced && !immediate_func) module_put(klp_transition_patch->mod); /* Prevent klp_ftrace_handler() from seeing KLP_UNDEFINED state */ @@ -642,4 +644,6 @@ void klp_force_transition(void) for_each_possible_cpu(cpu) klp_update_patch_state(idle_task(cpu)); + + klp_forced = true; } It is still better than immediate, because it is a "ex post" action. We can also try to improve later. We could remember all forced tasks and reenable rmmod once those tasks are really migrated ("shadow migration"). Thoughts are really welcome here. Miroslav From 1584140406062067527@xxx Wed Nov 15 13:53:38 +0000 2017 X-GM-THRID: 1584140406062067527 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread