Received: by 10.213.65.68 with SMTP id h4csp1251021imn; Wed, 21 Mar 2018 06:26:59 -0700 (PDT) X-Google-Smtp-Source: AG47ELv1jau7ho1SxocWmAgN9YD3dmVZKUV2lg1q58bTjXCqGOFFjAqCArBVN+XZXmPfjP/cALd1 X-Received: by 2002:a17:902:7804:: with SMTP id p4-v6mr21069649pll.17.1521638819709; Wed, 21 Mar 2018 06:26:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521638819; cv=none; d=google.com; s=arc-20160816; b=p9dDrh2WcprXjbDyiCvG4vy+UjSu448yl2Hnm1X/nyyebUg+WQxhnfpogYujfe2qOy BscY8VDVsFKQxrwT8aQzgbRMW2h67epcxdl3RY30AeOoq/tDwWKn5TMYAiNBlZQJhmoD RKzBmnGuSfQiE9viooLMv6QZhW6xK/DOLRRU0kzojeNEMH1hGPECJnZDsatPqkYZuj9R nvM2LSa1ab3plfgK2HWeZnNJWq1k4gOYOiVmdswGMaCXByGZz4PeGHD0PIonq8B6yd2+ iKibqbNvGXMsJyBb3GgyRmzQXWQOlQ/e1ZnWDM/wcbms//YBTkyjsooAoovvfzoyYHIj 3eDQ== 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=V6mm/4Tb7zBHTwRVHTzPPCTWaxa1UfRCkljkv3soMb0=; b=rlZc2fmTiIWim6GkGea4S1YuYzOJwz8R94rwtHUZjsHsglevzlin7lseKzphnCpcJ1 J+RA8mPpHnQ1If56V8qK68QY7iAT4NmDK0ZCnk+dLLkZyRH7thIvOBqSckQrpv4DpOWi w2wwukPAqjiMGQneXwzlzz+M8cZuImTYu5MCr8TTPrEuzYA9kAZ+SVyscTOQXFLlWTO5 wpij8CDWSeUTgrqeuEb5VrcBDWu6ETvmWgFH4Ryz2s1XpO1FJ//uRGO6PxgA45Lowr3f Bp2n88EFZLWFy5ivtLQR6nzhWI0aS8xtsK/K7v5/JiZBCCRYR24w1TM8G+Pse4SMbJbh cBkw== 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 v11-v6si4207866ply.427.2018.03.21.06.26.45; Wed, 21 Mar 2018 06:26:59 -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 S1752277AbeCUNYI (ORCPT + 99 others); Wed, 21 Mar 2018 09:24:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:45696 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751899AbeCUNXv (ORCPT ); Wed, 21 Mar 2018 09:23:51 -0400 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 0B821ACDB; Wed, 21 Mar 2018 13:23:50 +0000 (UTC) Date: Wed, 21 Mar 2018 14:05:14 +0100 (CET) From: Miroslav Benes To: Josh Poimboeuf cc: Petr Mladek , Jiri Kosina , Joe Lawrence , Jessica Yu , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] livepatch: Allow to unregister or free shadow data using a custom function In-Reply-To: <20180314193217.jl2pkzikzrk7wgpz@treble> Message-ID: References: <20180313155448.1998-1-pmladek@suse.com> <20180313155448.1998-3-pmladek@suse.com> <20180314193217.jl2pkzikzrk7wgpz@treble> 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, 14 Mar 2018, Josh Poimboeuf wrote: > On Tue, Mar 13, 2018 at 04:54:48PM +0100, Petr Mladek wrote: > > We might need to do some actions before the shadow variable is freed. > > For example, we might need to remove it from a list or free some data > > that it points to. > > > > This is already possible now. The user can get the shadow variable > > by klp_shadow_get(), do the necessary actions, and then call > > klp_shadow_free(). > > > > This patch allow to do this a more elegant way. The user could implement > > the needed actions in a callback that is passed to klp_shadow_free() > > as a parameter. The callback usually does reverse operations to > > the init_func that can be called by klp_shadow_*alloc(). > > > > It is especially useful for klp_shadow_free_all(). There we need to do > > these extra actions for each found shadow variable with the given ID. > > > > Note that the memory used by the shadow variable itself is still released > > later by rcu callback. It is needed to protect internal structures that > > keep all shadow variables. But free_func is called immediately. The shadow > > variable must not be access anyway after klp_shadow_free() is called. > > The user is responsible to protect this any suitable way. > > > > Be aware that free_func callback is called under klp_shadow_lock. It is > > the same as for init_func in klp_shadow_alloc(). > > > > Signed-off-by: Petr Mladek > > Makes sense, though I'm not sure "free" is the right name: > > a) "free" isn't the opposite of "init"; and > > b) it may be used for things other than freeing. > > Shall we call them constructor/destructor? Agreed. _ctor/_dtor both sound better. Miroslav