From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031954AbbKEJ2R (ORCPT ); Thu, 5 Nov 2015 04:28:17 -0500 Received: from mx2.suse.de ([195.135.220.15]:38841 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031838AbbKEJ2O (ORCPT ); Thu, 5 Nov 2015 04:28:14 -0500 Date: Thu, 5 Nov 2015 10:28:13 +0100 (CET) From: Jiri Kosina X-X-Sender: jkosina@pobox.suse.cz To: Josh Poimboeuf cc: Miroslav Benes , Seth Jennings , Vojtech Pavlik , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, "Cyril B." Subject: Re: [PATCH] livepatch: Cleanup page permission changes In-Reply-To: <20151104231252.GA28254@treble.redhat.com> Message-ID: References: <132b018cfe2c6e4cef4d1b62ac3ed70333734111.1446494413.git.jpoimboe@redhat.com> <20151103174228.GN27488@treble.redhat.com> <20151104231252.GA28254@treble.redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) 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 On Wed, 4 Nov 2015, Josh Poimboeuf wrote: > > > int klp_write_module_reloc(struct module *mod, unsigned long type, > > > unsigned long loc, unsigned long value) > > > { > > > - int ret, numpages, size = 4; > > > - bool readonly; > > > + int size = 4; > > > > BTW I don't see a reason to have 'size' signed here. > > It was already signed to begin with, but I can change it to size_t. Yes, I know, it's not really related to this patchset, but I stumbled upon it during review. > > > +#ifdef CONFIG_DEBUG_SET_MODULE_RONX > > > +static void set_page_attributes(void *start, void *end, > > > + int (*set)(unsigned long start, int num_pages)) > > > +{ > > > + unsigned long begin_pfn = PFN_DOWN((unsigned long)start); > > > + unsigned long end_pfn = PFN_DOWN((unsigned long)end); > > > + > > > + if (end_pfn > begin_pfn) > > > + set(begin_pfn << PAGE_SHIFT, end_pfn - begin_pfn); > > > +} BTW is there any reason not to make use of the function from module.c which does exactly the same, instead of copy pasting it all around? > > > +static void set_module_ro_rw(struct module *mod) > > > +{ > > > + set_page_attributes(mod->module_core, > > > + mod->module_core + mod->core_ro_size, > > > + set_memory_rw); > > > +} > > > +static void set_module_ro_ro(struct module *mod) > > > > Honestly, I find both the function names above horrible and not really > > self-explanatory (especially the _ro_ro variant). At least comment, > > explaining what they are actually doing, or picking up a better name, > > would make the code much more self-explanatory in my eyes. > > Being the patch author, naturally the function names make sense to me. :) > set_module_ro_ro() means "set the module's read-only area to have > read-only permissions." > > Do you have any suggestions for a better name? I'd even say it's superfluous to have the functions at the first place, and just calling set_page_attributes() directly makes the intent clear enough already. Thanks, -- Jiri Kosina SUSE Labs