Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752635AbdHKG1p (ORCPT ); Fri, 11 Aug 2017 02:27:45 -0400 Received: from mx2.suse.de ([195.135.220.15]:49317 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750815AbdHKG1n (ORCPT ); Fri, 11 Aug 2017 02:27:43 -0400 Date: Fri, 11 Aug 2017 08:27:41 +0200 (CEST) From: Miroslav Benes To: Joe Lawrence cc: live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Poimboeuf , Jessica Yu , Jiri Kosina , Petr Mladek Subject: Re: [PATCH v3] livepatch: introduce shadow variable API In-Reply-To: <20170810160432.3vccq4clvg7pi7m4@redhat.com> Message-ID: References: <1501262722-26502-1-git-send-email-joe.lawrence@redhat.com> <1501262722-26502-2-git-send-email-joe.lawrence@redhat.com> <20170810160432.3vccq4clvg7pi7m4@redhat.com> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1380 Lines: 46 > > > +/* > > > + * klp_shadow_set() - initialize a shadow variable > > > + * @shadow: shadow variable to initialize > > > + * @obj: pointer to parent object > > > + * @id: data identifier > > > + * @data: pointer to data to attach to parent > > > + * @size: size of attached data > > > + */ > > > +static inline void klp_shadow_set(struct klp_shadow *shadow, void *obj, > > > + unsigned long id, void *data, size_t size) > > > +{ > > > + shadow->obj = obj; > > > + shadow->id = id; > > > + > > > + if (data) > > > + memcpy(shadow->data, data, size); > > > +} > > > + > > > +/** > > > + * klp_shadow_add() - add a shadow variable to the hashtable > > > + * @shadow: shadow variable to add > > > + */ > > > +static inline void klp_shadow_add(struct klp_shadow *shadow) > > > +{ > > > + hash_add_rcu(klp_shadow_hash, &shadow->node, > > > + (unsigned long)shadow->obj); > > > +} > > > > It would be nice to add a comment that a caller must hold klp_shadow_lock > > spinlock. > > Since shadow_match(), klp_shadow_set(), and klp_shadow_add() are all in > the same boat, I can mention the lock for those functions as well. Yes, please. > BTW, > is there a convention to drop the "klp_" for static, local routines? I > should be consistent here. Oh, I didn't notice missing "klp_" in shadow_match. We have a prefix everywhere, so add it, please. Thanks, Miroslav