Received: by 10.223.176.5 with SMTP id f5csp476929wra; Fri, 9 Feb 2018 02:07:38 -0800 (PST) X-Google-Smtp-Source: AH8x224eaqYZvhqIMt2bVhxcjLC4DZm/VAd0quzVFF9r+gSug/QBdMNpkKq5JxYveLPhV24aBRci X-Received: by 2002:a17:902:8bc5:: with SMTP id r5-v6mr2044914plo.213.1518170857987; Fri, 09 Feb 2018 02:07:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518170857; cv=none; d=google.com; s=arc-20160816; b=qcVuv/ItqDb3RvD7dt/aKBmz/Y0BY801utg0KZTm2I8AqgX8KWtugbFase5eKI8DL3 kuuolX0b+oino1Ov1BDqlMvE1JZgUoxi0B8JhLwaRfguAJ+5ph+SHGFVf/6U5ipi3kGT Ye0Km0pH5lYvcP75kFfm1BmaVb0KLzSeJPz6qSkZ9etexa44C0MGu5QgCWpITA0J6LZh KZLB4Pp25ygXTP4tVOB+OOegftvsOBNj+CIBWlXNYLZEuTm5edwOUwTUBCDXcItXMZ03 IcflWv5RpEMOYEoX4JFgzwyotDKOnXnRb6ZXfjB8Qa9PoDobtU+AxNqTCwHBzQqT4q0f t40A== 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=BOiEC8niwdTfGEsL+RbrQtSCNFfCsgrjzYZpyHhsJLI=; b=H60SLqloqBjpjKPeq/91ljI/JWV6TUnQENgqYUokuopXVXuCBcMWM0KsiYGoaqyC5v eWep7dOgVS86nk3e76O5lM6upPAZTKorAN3nK5l4zgqlbmBtkRwSCEydRLWFv6DxwqxG MWItsnIZYsk60vmX/yjp/h1NFE6o5dyXm9Ms3vxmAce+Fks0Z2HNaWU7MDEJD9NvS+tF AUP0FDhCooD8TG6CLqXPACHfPl9prirf/EPnT5Y2ASRj//MVnwmHsR8ek/vZDHXuQWgr 99U8pUcmyvblYOmeonzo96Am+/WMs/u4IYB6/MSAHC/0BRtBVSgPPCseEQy8kcG9SL1C 5QIw== 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 h1-v6si1361247pln.138.2018.02.09.02.07.20; Fri, 09 Feb 2018 02:07:37 -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 S1751248AbeBIKGQ (ORCPT + 99 others); Fri, 9 Feb 2018 05:06:16 -0500 Received: from mx2.suse.de ([195.135.220.15]:47387 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751034AbeBIKGO (ORCPT ); Fri, 9 Feb 2018 05:06:14 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C9F59AE03; Fri, 9 Feb 2018 10:06:12 +0000 (UTC) Date: Fri, 9 Feb 2018 11:06:11 +0100 (CET) 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 v7 3/7] livepatch: Initial support for dynamic structures In-Reply-To: <20180206103424.10829-4-pmladek@suse.com> Message-ID: References: <20180206103424.10829-1-pmladek@suse.com> <20180206103424.10829-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 Tue, 6 Feb 2018, Petr Mladek wrote: > From: Jason Baron > > We are going to add a feature called atomic replace. It will allow to > create a patch that would replace all already registered patches. > For this, we will need to dynamically create funcs and objects > for functions that are not longer patched. > > This patch adds basic framework to handle such dynamic structures. > > It adds enum klp_func_type that allows to distinguish the dynamically > allocated funcs' structures. Note that objects' structures do not have > a clear type. Namely the static objects' structures might list both static > and dynamic funcs' structures. > > The function type is then used to limit klp_free() functions. We will > want to free the dynamic structures separately when they are not > longer needed. At the same time, we also want to make our life easier, > and introduce _any_ type that will allow to process all existing > structures in one go. > > We need to be careful here. First, objects' structures must be freed > only when all listed funcs' structures are freed. Also we must avoid > double free. Both problems are solved by removing the freed structures > from the list. > > Also note that klp_free*() functions are called also in klp_init_patch() > error path when only some kobjects have been initialized. The other > dynamic structures must be freed immediately by calling the respective > klp_free_*_dynamic() functions. > > Finally, the dynamic objects' structures are generic. The respective > klp_allocate_object_dynamic() and klp_free_object_dynamic() can > be implemented here. On the other hand, klp_free_func_dynamic() > is empty. It must be updated when a particular dynamic > klp_func_type is introduced. > > Signed-off-by: Jason Baron > [pmladek@suse.com: Converted into a generic API] > Signed-off-by: Petr Mladek > Cc: Josh Poimboeuf > Cc: Jessica Yu > Cc: Jiri Kosina > Cc: Miroslav Benes This patch introduces klp_get_or_add_object(), but it is not used here. One of the later patches adds its call site. GCC warns about this. I like it being introduced here, because it belongs to the patch. Someone may complain though. Also klp_free_objects() is not declared as static and sparse complains about it. Petr, you can make it static here and drop the keyword later. Otherwise it looks good. Acked-by: Miroslav Benes Miroslav