Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp737542imm; Fri, 12 Oct 2018 06:02:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gThV8/gguL4hxFNxy+b1lA+WxRBzcV/A9W/0fkFGrOtapR5unBd8Uw0R3ypHJmiT/JLor X-Received: by 2002:a63:450b:: with SMTP id s11-v6mr5598719pga.301.1539349359590; Fri, 12 Oct 2018 06:02:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539349359; cv=none; d=google.com; s=arc-20160816; b=eNOi/FTlw58xxPwG1I+7IGJI07b2P4Asf/tSeBruI69djW4dUGIYCS9BWjxxy4pTNN Me+GfjZ7E54UQBuifv09FOomoQhqyBIUBqBtNAIyY4/H0uNRdsMIS/s8yVkMv4ws9fGD 7yH9bZpXxw1AIWU+NQaLaUo9pjUrmELdlPFHrU2ekO2ETRJze5kfGSHyhKbSakc0LvZ/ H4qq3vT3GuPVMqiQpyBM7QwXoMUDmxRsDEOGvBrYeY/bwX1uiPbTPJJG7Y4oqiIgETE2 +XQyXaZ3JtnjBNyITushNovOibM2Fkn9hvAEHGn7X/IGFJbhfqtsuekgfgcVvuGUE1lb Z0/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=WoPV9JfZ+sDLxvaXqPIDV+pag7dnTSrG5JKexfy5Se0=; b=znNfDDqkkI7WrXqt63mE8ME+Lmc8TkQ2g166Rpnk8UXJRA8ODWEtpflR2R6uqFg6AA TNnoRm3y/JimlWcLB3OH/6Nu3+Q+Ru/cDXJ+c5NINTo2HpxsVgdWDS2tuCBfWYPnV3OY NVzmf7VosrIFKcJ1PkV1A5pSlqd69RGL8H/AXk+ChVdrtOE9JxIiYhnxmQnZdUFqkXZp ejlBtPlVcVWnKAbXWZ5OFWocK3Dv0SgPpT51IdvbYX19U1XzqcwlrZ335dTNKkdgWZpw IMMK96A1aiq9gRexQVKlBa+MAwl7rC5MfgZbnMDYT80mkYGlkuiULbGAaHTcA5LZ69st o+aw== 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 11-v6si1352808plc.224.2018.10.12.06.02.22; Fri, 12 Oct 2018 06:02:39 -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 S1728668AbeJLUdo (ORCPT + 99 others); Fri, 12 Oct 2018 16:33:44 -0400 Received: from mx2.suse.de ([195.135.220.15]:46564 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727838AbeJLUdo (ORCPT ); Fri, 12 Oct 2018 16:33:44 -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 12C77AE86; Fri, 12 Oct 2018 13:01:21 +0000 (UTC) Date: Fri, 12 Oct 2018 15:01:20 +0200 From: Petr Mladek To: Miroslav Benes 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 Message-ID: <20181012130120.f5berowklyccd7lj@pathway.suse.cz> References: <20180828143603.4442-1-pmladek@suse.com> <20180828143603.4442-7-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. + 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. > > @@ -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() ;-) Best Regards, Petr