Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1333287

Re: Allowing external modules to run across more configs and distros

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From "David F." <df7729@gmail.com>
Newsgroups linux.kernel
Subject Re: Allowing external modules to run across more configs and distros
Date Sat, 13 Feb 2016 09:20:01 +0100
Message-ID <r1DAR-2bd-1@gated-at.bofh.it> (permalink)
References <r1D7Q-1Ms-5@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=EoF+/pEyW3wmfNaVdGfm7sJZ5ZZnoAAjCiuQ0wRjalg=; b=Rz3citCTE4hQeK1ab0Jqz+xAQvaaSFny0ooKngrdaRQXQ1Qx5YC8ffoAIGZdYFbG34 +OX3g0G+yiBqD8kxO0XEpDSrKuaDe73eobMfv8c3Tb+xglXx/bS75FAjCQT6wfAjpPT6 frKRnn3utZ4GxN8ZeE156eI7qG/C62KSqZwRIsLRXm62PXudxZvUrDPbcz71mxrMmYF+ ckHJLYWxHJDsc3wz2h/dhJqApcKzBKc2mo3Mic+BIbDCBiVebHKHsT3MtDgGWaLLYjeK +tegxgYrvGvAB7bb+L1cWPdIs2Y0of+JQ4ktHSx9r52V/RiCY/U8BmCwdQ421y2ySBQM NnCA==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=EoF+/pEyW3wmfNaVdGfm7sJZ5ZZnoAAjCiuQ0wRjalg=; b=FPsW2reFhNrZzEHFm24/eICHg2r4+8NgpIGJh8ZO33mLiKPf9RKAjLyWnR5A+/W0QD P/XQmVyYMOMLEGal5G9DfXb01GWXk/gT1oC5nEEeM9OXipRnM1IkSEk6BAeLvvXz+KXj M/GfSBvA2TBNmgZE5NrPfhYZ2ZJs1qTVJlbTjeOAN4mudHPAkBZ6q1+ma5xkc4uq86hS IxWiCk/E/QDZvXW6fIuOSqP0t6SU+8Om1LnyJ/3p4mq2JKSu7oCOeblGvRd8S9ts9p4i 5m5pdg/1dYu1liS+0R9cOhsn6NXD2K9nbvlPsxfjIL3Wo6tQJ3rfowEaCHrOIKBjofli WsjA==
X-Gm-Message-State AG10YOSPoAjBB/O5DIzjIb3KzUaC4zZNXyvcnRgAVUZvDuNYKl+hxSRWyTSeFi1PXi0mmFoQCB8TQF42R/TssQ==
MIME-Version 1.0
X-Received by 10.202.227.12 with SMTP id a12mr4608865oih.49.1455351189623; Sat, 13 Feb 2016 00:13:09 -0800 (PST)
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 42
Organization linux.* mail to news gateway
X-Original-Date Sat, 13 Feb 2016 00:13:09 -0800
X-Original-Message-ID <CAGRSmLtxYYDgLXsPz284OUmaNF6SKJhaZxSgupd_Am0E2Am7aA@mail.gmail.com>
X-Original-References <CAGRSmLu8iHLC-vLRdXu3QYpOZspGbwKb0eRTFe_iA4KCxCx6nQ@mail.gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1333287

Show key headers only | View raw


After sending the below, I realized that if someone doesn't want to
have to dereference a pointer it could still be done the same way and
just omitting the member variable (options).  You would just always
allocate (sizeof (struct module)+sizeof(struct modconfigopts)) and to
access the options, use a different macro: #define MOD_OPT(m) ((struct
modconfigopts*)((m)+1))  --or-- #define MOD_OPT(m) ((struct
modconfigopts*)((int8_t*)(m)+sizeof(*m)))
example of when an optional item is reference:
MOD_OPT(THIS_MODULE)->param_lock

now you don't have any dereferencing of the pointer.


On Fri, Feb 12, 2016 at 11:45 PM, David F. <df7729@gmail.com> wrote:
> While creating a linux module that should be usable across a wide
> array of linux versions and builds, I've run into struct modules
> (THIS_MODULE) being a problem.  It's the only internal struct accessed
> as a requirement to struct block_device_operations .owner.   It's a
> bit annoying for this module to be rejected for nothing it has any
> interest in using.  So I was thinking of a quick solution but don't
> want to waste my time if people will resist it (not sure when I'll
> have time to do it, but should be able to do it quickly once i'd have
> all the source local).  The idea is:
>
> Take all #if defines out of the struct module and place them in a
> separate struct (struct modconfigopts).  Place a single member
> variable at the end of struct modules as void * (void *options) to
> access the options.  Have a single macro to access the options member
> variable for the internal code that access it (#define MOD_OPT(v)
> ((struct modconfigopts*)(v)).  So internal code would use
> module->MOD_OPT(options)->param_lock for example.
>
> When the module structure is created, it would initialize the options
> member variable (the memory allocated (sizeof(struct
> module)+sizeof(struct modconfigopts)) could be contiguous so it's like
> one big structure, then cleanup would be the same).
>
> Doing this should then allow "external" modules that don't need access
> to the "internal" config options to continue to load and work across a
> much greater range of Linux distributions.
>
> What do you think?

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Allowing external modules to run across more configs and distros "David F." <df7729@gmail.com> - 2016-02-13 08:50 +0100
  Re: Allowing external modules to run across more configs and distros "David F." <df7729@gmail.com> - 2016-02-13 09:20 +0100
    Re: Allowing external modules to run across more configs and distros "David F." <df7729@gmail.com> - 2016-02-13 17:10 +0100

csiph-web