Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp884380imu; Wed, 9 Jan 2019 08:00:58 -0800 (PST) X-Google-Smtp-Source: ALg8bN5DM951pvBtH+xH1Dj4WDk3CO730iq3LjdNy213DYYAeRkVN3gmojhhp1/BUtVLK8f3UU9Z X-Received: by 2002:a63:2905:: with SMTP id p5mr805402pgp.178.1547049658789; Wed, 09 Jan 2019 08:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547049658; cv=none; d=google.com; s=arc-20160816; b=U+GTQ9jCGqcTkftFXENBrniIq9fYvcxZt9OJfJRL9Jle/Zr4kRGAffhiWzoknMfIMt JvrLl25VBrHyWdIrqz3ATES2MhG1huJfUoUdNYIyqkPktiYKcz9vXOidJIVgCDJNWrjp 4T16qBq5ORJYyI4/1KSNKtejjYEypF8Lr1DDlVh7ImVPQ95HTyxepZ4xdfBI8fC07lPg mjk5u+yW8Jt01/aQJSPAQbsmHc8QVI6+5LaAnZddXvyVy1urO983Xm/o9kpYZd2YWs4a olMkkfXoEZYCTOD0yR62TIMCz25gvG1wiPmbwTS58awKe6nacfzm/bry8dc8Te+IpvfT 4hxw== 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=/N8SjWVcmqTuFaoy5XZgOQbJUoUdaqpffJS4obydgdM=; b=M/Hs6N/b/ANhOeS1YI7lw5lz16+5Igur7A37THN9I1KvkqYF1bX7NCNGYCmknoA1+/ /I9uT2xmYIsaOUSfzxXZ8YYyP0dK7fM5S2NOZ7/mnAZrYrd8EkoZecvP9a6GGQABjE8C MnNjtTdGnYUCpO+33kdu70QIRwmLa19PcVKwhJkGob7TZqZy7xvxC22Jv8z5xiHGukdQ 43gTwjz/dyoxvwRFxbMAkq2Cr29U0lLc5+He7AH4OexAFyt2gwIdjxcClDSLRuearpz1 dkl3J0YbSG9Ly5R79M0PIkiLGAzIwuMlpPxglEw5ktPJBRfnQ4aItPlEezAFgobH9luR Qxzw== 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 x16si10733082pga.407.2019.01.09.08.00.40; Wed, 09 Jan 2019 08:00:58 -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 S1731349AbfAIOfw (ORCPT + 99 others); Wed, 9 Jan 2019 09:35:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:33886 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729829AbfAIOfw (ORCPT ); Wed, 9 Jan 2019 09:35:52 -0500 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 2B128AD4C; Wed, 9 Jan 2019 14:35:51 +0000 (UTC) Date: Wed, 9 Jan 2019 15:35:49 +0100 (CET) From: Miroslav Benes To: Petr Mladek cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Joe Lawrence , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: Re: [PATCH v15 03/11] livepatch: Consolidate klp_free functions In-Reply-To: <20190109124329.21991-4-pmladek@suse.com> Message-ID: References: <20190109124329.21991-1-pmladek@suse.com> <20190109124329.21991-4-pmladek@suse.com> 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, 9 Jan 2019, Petr Mladek wrote: > The code for freeing livepatch structures is a bit scattered and tricky: > > + direct calls to klp_free_*_limited() and kobject_put() are > used to release partially initialized objects > > + klp_free_patch() removes the patch from the public list > and releases all objects except for patch->kobj > > + object_put(&patch->kobj) and the related wait_for_completion() > are called directly outside klp_mutex; this code is duplicated; > > Now, we are going to remove the registration stage to simplify the API > and the code. This would require handling more situations in > klp_enable_patch() error paths. > > More importantly, we are going to add a feature called atomic replace. > It will need to dynamically create func and object structures. We will > want to reuse the existing init() and free() functions. This would > create even more error path scenarios. > > This patch implements more straightforward free functions: > > + checks kobj_added flag instead of @limit[*] > > + initializes patch->list early so that the check for empty list > always works > > + The action(s) that has to be done outside klp_mutex are done > in separate klp_free_patch_finish() function. It waits only > when patch->kobj was really released via the _start() part. > > The patch does not change the existing behavior. > > [*] We need our own flag to track that the kobject was successfully > added to the hierarchy. Note that kobj.state_initialized only > indicates that kobject has been initialized, not whether is has > been added (and needs to be removed on cleanup). > > Signed-off-by: Petr Mladek > Cc: Josh Poimboeuf > Cc: Miroslav Benes > Cc: Jessica Yu > Cc: Jiri Kosina > Cc: Jason Baron Acked-by: Miroslav Benes Miroslav