Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4094586imm; Mon, 15 Oct 2018 09:02:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV61Zv+Zu2yTt3HXjmB4qbdVqP+E14bxPWwVjE2XT/42l6NZRqMOsjgqWAN82LhW/+CIhUJG2 X-Received: by 2002:a65:580d:: with SMTP id g13-v6mr15550066pgr.370.1539619350129; Mon, 15 Oct 2018 09:02:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539619350; cv=none; d=google.com; s=arc-20160816; b=ecjFmxJGm9M13AXWY2TiDjhnGVonwFKrCtxLU12seLR8UO5RlL5LckQjoAnXwxhTQX T+TFxrl6xs9D6hAHpdeZTNvOIsXhTmm4XWr4V7rwYhZ9gwv2QdIZx+zMy9sudHsxfWmv D3zZxd0+0G48pV0Md+w//GYvUn7+9oiAZp2xFNgHAslfFotYCTwwotku8fXJPw7nZChR yTKkznLJMlVjZT4gCW9IfpOw1+e7zWR02M3xFutiF99jn3eLDeGY/ECRj/yL1A7SEwlm SbmlsZ66UmJ2CuP/34D9skfZFElx1fbbLbs26V7LZD7l0rYwkt1tHrvM58XOLWxK1ui6 gFeA== 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; bh=wbq3RKmVXsQ8TcxTU5jGtvWmdjpecd08oA4rRAluxb0=; b=1CyEz3nO1/uHLaigynU3nlzUeqDcu1R6WNEDhCFEPZqPA/G96JbF9m3T44PkBnomKR 2p3zBE72GUCFNM7lNR9OdYlJAeUmd5mDBAV44n+zJW7h1EpERWxkydhBm5a9JduMEfFS LypHwmqhru70wEqHmpMD3wgbXYKCoSHPO8ogipA62i1FpPypMNvrm1d6gltriuEJnNx5 3NmgHOKX/c5sqw5QHuBn5JfoRnuoHNZoJTRuFGHnG6ckaoPhVjk8ew3C5U49+7c1hCkJ cAA92IY7knumFdYo55D+n2TdR4bh+nnHCp/p9XDexrw61gQmuG9xzGIOHyUf5Wm4hDlm Wa4g== 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 j24-v6si9754999pff.42.2018.10.15.09.02.11; Mon, 15 Oct 2018 09:02:30 -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 S1726703AbeJOXrh (ORCPT + 99 others); Mon, 15 Oct 2018 19:47:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:60574 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726528AbeJOXrg (ORCPT ); Mon, 15 Oct 2018 19:47:36 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AAC63AFD9; Mon, 15 Oct 2018 16:01:44 +0000 (UTC) Date: Mon, 15 Oct 2018 18:01:43 +0200 (CEST) From: Miroslav Benes To: Petr Mladek cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Joe Lawrence , Jessica Yu , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v12 06/12] livepatch: Simplify API by removing registration step In-Reply-To: <20181012130120.f5berowklyccd7lj@pathway.suse.cz> Message-ID: References: <20180828143603.4442-1-pmladek@suse.com> <20180828143603.4442-7-pmladek@suse.com> <20181012130120.f5berowklyccd7lj@pathway.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 Fri, 12 Oct 2018, Petr Mladek wrote: > On Wed 2018-09-05 11:34:06, Miroslav Benes wrote: > > On Tue, 28 Aug 2018, Petr Mladek wrote: > > > Also the API and logic is much easier. It is enough to call > > > klp_enable_patch() in module_init() call. The patch patch can be disabled > > > by writing '0' into /sys/kernel/livepatch//enabled. Then the module > > > can be removed once the transition finishes and sysfs interface is freed. > > > > I think it would be good to discuss our sysfs interface here as well. > > > > Writing '1' to enabled attribute now makes sense only when you need to > > reverse an unpatching transition. Writing '0' means "disable" or a > > reversion again. > > > > Wouldn't be better to split it to two different attributes? Something like > > "disable" and "reverse"? It could be more intuitive. > > > > Maybe we'd also find out that even patch->enabled member is not useful > > anymore in such case. > > I though about this as well. I kept "enabled" because: > > + It keeps the public interface the same as before. Most people > would not notice any change in the behavior except maybe that > the interface disappears when the patch gets disabled. Well our sysfs interface is still in a testing phase as far as ABI is involved. Moreover, each live patch is bound to its base kernel by definition anyway. So we can change this without remorse, I think. > + The reverse operation makes most sense when the transition > cannot get finished. In theory, it might be problem to > finish even the reversed one. People might want to > reverse once again and force it. Then "reverse" file > might be confusing. They might not know in which direction > they do the reverse. I still think it would be better to have a less confusing interface and it would outweigh the second remark. > > > @@ -846,17 +740,8 @@ static int __klp_enable_patch(struct klp_patch *patch) > > > if (WARN_ON(patch->enabled)) > > > return -EINVAL; > > > > > > - /* enforce stacking: only the first disabled patch can be enabled */ > > > - if (patch->list.prev != &klp_patches && > > > - !list_prev_entry(patch, list)->enabled) > > > - return -EBUSY; > > > - > > > - /* > > > - * A reference is taken on the patch module to prevent it from being > > > - * unloaded. > > > - */ > > > - if (!try_module_get(patch->mod)) > > > - return -ENODEV; > > > + if (!patch->kobj.state_initialized) > > > + return -EINVAL; > > > > I think the check is not needed here. __klp_enable_patch() is called right after > > klp_init_patch() in klp_enable_patch(). > > I would keep it. Someone might want to call this also from other > location. Even we used to do it from enable_store() ;-) Ok, I don't mind in the end. Miroslav