Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp267240pxj; Fri, 14 May 2021 03:00:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmKwDsPQWz018k3nwG8/Iji1v079G6Da1lxvGu+v0zBCQpds9Z93PONPeDbNJJMIln1rXi X-Received: by 2002:a92:d1ce:: with SMTP id u14mr28904157ilg.61.1620986439407; Fri, 14 May 2021 03:00:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620986439; cv=none; d=google.com; s=arc-20160816; b=fpiLieT4M5noqUoiB9FfH27TVXiprgzVJkf+jHWDIpnVUUozC4Vz7hg4KgSkDnWhAH CjMsMCnynkTrRSLkYK2MG+TIyfA9/7HDTt4NTl/1jkB++ZDXfDwm0cJIBCWHnpjniG8U tATmO6OcGJfYJaFT0/iAUwGNdUN/qt3YaUoDlKIVlHjX0foWirrwXlVvJrrXVQv4nmVK ER+eeqEen+IWCV2A3J3Rp0t1DM1v6GbobgWmJnpUCDt4JucNDHFVMkp9MKt9zMnn2CGW zSZAYeFmMM7SELq0N/VK5U5xUMwW6fSCW0EWO9hxFlkh049+iWHwaT5I1j2MeOuSTtMd nytA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:urom:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dyxNtnXQ9SC8airUFb9FyJ8fYYpUFs+0E1m99aNDGbk=; b=Oi6hYRADBeYiLFCEdT3Ge+7nVBUc0rZ9WEXYJUvndfWEfTdcv/IKVBoW+SFMPPrOUZ qUfg7SG5XBfM+LwEcDQjYyNb3wlvtugHwhLd+GVF/VU0VlSF4GZ4HITdpOzbSNcnluUJ iuuyA/Z/L369900plpF+qD1mZMjfwEpUVzhaqNN0jrPXWpvR6+pVgeqGQHsPjzgGvu7L bV7UNURyXtHmYaC2CWSURxUg1IylUk6M0r/HmCm/sO9WFls02+Q3Bcgi1dxJM7eJSxIN fezvey7pZnSoB9i2w6oD1kWyBfybG16t2LFFDB8siQAz8IXgBFYKr/ble7hqvmn434xo M/OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Coc4Gx2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s8si6245711iop.88.2021.05.14.03.00.26; Fri, 14 May 2021 03:00:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Coc4Gx2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232960AbhENHNo (ORCPT + 99 others); Fri, 14 May 2021 03:13:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:51854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230247AbhENHNo (ORCPT ); Fri, 14 May 2021 03:13:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A46E161221; Fri, 14 May 2021 07:12:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620976353; bh=QqdCFuLkw9HqiWLBqf1BMhrJfMvdesvkwhgenRv4SSc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Coc4Gx2+/36PMdCoeHMZPRxFV02rZOiaUqh4tiCUmqmyzzRzk4bcvmBAYVCbz24Ah SEBN0O5QGIHvw4fAorqzNvEwyPPi1YicqmmsHggG+uUR+TMYhunay0WrjqvOtuzULQ MpAWYkzhkvByOZyrNWIfTcm4M36iKH8SQTHjwxCK1fX6piiXtr7y+bk4OSkL1KKxEY CwpX8MfMUJ4K0MBCnmcR61ZkdoskJug44ioDJZQGywXjnT/9Nsk4nfrYK3N98aPGJS FI+YiVNENWJNcR+0r6mKjFMyXzxYaxUEvfZJw910dX471zjZIc6OFT3a/0WFHzLBQq dq8/7w1+B31mw== Date: Fri, 14 May 2021 09:12:29 +0200 From: Jessica Yu To: Russell King - ARM Linux admin Cc: linux-kernel@vger.kernel.org, Peter Zijlstra Subject: Re: [PATCH] module: check for exit sections in layout_sections() instead of module_init_section() Message-ID: References: <20210512144653.3726-1-jeyu@kernel.org> <20210512160651.GP1336@shell.armlinux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210512160651.GP1336@shell.armlinux.org.uk> urom: Jessica Yu X-OS: Linux p200300cbcf361a0029e37a38368d6727.dip0.t-ipconnect.de 5.12.0-2-default x86_64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Russell King - ARM Linux admin [12/05/21 17:06 +0100]: >Hi, > >On Wed, May 12, 2021 at 04:46:53PM +0200, Jessica Yu wrote: >> diff --git a/kernel/module.c b/kernel/module.c >> index 173a09175511..a5c9842371b1 100644 >> --- a/kernel/module.c >> +++ b/kernel/module.c >> @@ -2430,6 +2430,9 @@ static void layout_sections(struct module *mod, struct load_info *info) >> if ((s->sh_flags & masks[m][0]) != masks[m][0] >> || (s->sh_flags & masks[m][1]) >> || s->sh_entsize != ~0UL >> +#ifndef CONFIG_MODULE_UNLOAD >> + || module_exit_section(sname) >> +#endif >> || module_init_section(sname)) > >How about a helper to make this a bit easier in both these places to >make the code more undertsandable? I think the great value comes from >the resulting change in the second hunk. > >static bool module_evictable_section(const char *sname) >{ >#ifndef CONFIG_MODULE_UNLOAD > if (module_exit_section(sname)) > return true; >#endif > return module_init_section(sname); >} > >and then just use that above? > >> continue; >> s->sh_entsize = get_offset(mod, &mod->core_layout.size, s, i); >> @@ -2463,7 +2466,11 @@ static void layout_sections(struct module *mod, struct load_info *info) >> if ((s->sh_flags & masks[m][0]) != masks[m][0] >> || (s->sh_flags & masks[m][1]) >> || s->sh_entsize != ~0UL >> +#ifndef CONFIG_MODULE_UNLOAD >> + || (!module_init_section(sname) && !module_exit_section(sname))) >> +#else >> || !module_init_section(sname)) >> +#endif > >I find this a tad confusing, and this is the reason for my suggestion >above. With that, this becomes: > > || !module_evictable_section(sname)) > >which can be clearly seen is the opposite condition from the above >without doing mental logic gymnastics. Thanks Russell for the feedback! Yeah, agreed that it could be made easier to read - will respin with a helper function. Jessica