From: Qian Cai <cai@lca.pw>
To: James Y Knight <jyknight@google.com>
Cc: David Miller <davem@davemloft.net>,
Bill Wendling <morbo@google.com>,
Nick Desaulniers <ndesaulniers@google.com>,
sathya.perla@broadcom.com, ajit.khaparde@broadcom.com,
sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com,
Arnd Bergmann <arnd@arndb.de>,
David Howells <dhowells@redhat.com>,
"H. Peter Anvin" <hpa@zytor.com>,
netdev@vger.kernel.org, linux-arch@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
natechancellor@gmail.com, Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH] be2net: fix adapter->big_page_size miscaculation
Date: Mon, 22 Jul 2019 23:08:41 -0400 [thread overview]
Message-ID: <BE0991D9-65E7-43CA-A4B4-D3547D96291A@lca.pw> (raw)
In-Reply-To: <CAA2zVHqXDuMzBC6dD5AbepZc63nPdJ3WLYmjinjq01erqH+HXA@mail.gmail.com>
The original issue,
https://lore.kernel.org/netdev/1562959401-19815-1-git-send-email-cai@lca.pw/
The debugging so far seems point to that the compilers get confused by the
module sections. During module_param(), it stores “__param_rx_frag_size"
as a “struct kernel_param” into the __param section. Later, load_module()
obtains all “kernel_param” from the __param section and compare against the
user-input module parameters from the command-line. If there is a match, it
calls params[i].ops->set(¶ms[I]) to replace the value. If compilers can’t
see that params[i].ops->set(¶ms[I]) could potentially change the value
of rx_frag_size, it will wrongly optimize it as a constant.
For example (it is not
compilable yet as I have not able to extract variable from the __param section
like find_module_sections()),
#include <stdio.h>
#include <string.h>
#define __module_param_call(name, ops, arg) \
static struct kernel_param __param_##name \
__attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) = { \
#name, ops, { arg } }
struct kernel_param {
const char *name;
const struct kernel_param_ops *ops;
union {
int *arg;
};
};
struct kernel_param_ops {
int (*set)(const struct kernel_param *kp);
};
#define STANDARD_PARAM_DEF(name) \
int param_set_##name(const struct kernel_param *kp) \
{ \
*kp->arg = 2; \
} \
const struct kernel_param_ops param_ops_##name = { \
.set = param_set_##name, \
};
STANDARD_PARAM_DEF(ushort);
static int rx = 1;
__module_param_call(rx_frag_siz, ¶m_ops_ushort, &rx_frag_size);
int main(int argc, char *argv[])
{
const struct kernel_param *params = <<< Get all kernel_param from the __param section >>>;
int i;
if (__builtin_constant_p(rx_frag_size))
printf("rx_frag_size is a const.\n");
for (i = 0; i < num_param; i++) {
if (!strcmp(params[I].name, argv[1])) {
params[i].ops->set(¶ms[i]);
break;
}
}
printf("rx_frag_size = %d\n", rx_frag_size);
return 0;
}
next prev parent reply other threads:[~2019-07-23 3:08 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 19:23 [PATCH] be2net: fix adapter->big_page_size miscaculation Qian Cai
2019-07-12 22:46 ` David Miller
2019-07-13 0:27 ` Qian Cai
2019-07-13 0:50 ` David Miller
2019-07-18 21:01 ` Qian Cai
2019-07-18 21:10 ` Nick Desaulniers
2019-07-18 21:21 ` Bill Wendling
2019-07-18 23:26 ` Qian Cai
2019-07-18 23:29 ` David Miller
2019-07-19 21:47 ` Qian Cai
2019-07-22 21:13 ` Qian Cai
2019-07-22 22:58 ` James Y Knight
2019-07-23 3:08 ` Qian Cai [this message]
[not found] ` <CAGG=3QWkgm+YhC=TWEWwt585Lbm8ZPG-uFre-kBRv+roPzZFbA@mail.gmail.com>
2019-07-18 21:22 ` Nick Desaulniers
2019-07-18 21:28 ` Bill Wendling
2019-07-19 10:32 ` kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BE0991D9-65E7-43CA-A4B4-D3547D96291A@lca.pw \
--to=cai@lca.pw \
--cc=ajit.khaparde@broadcom.com \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=hpa@zytor.com \
--cc=jakub@redhat.com \
--cc=jyknight@google.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=morbo@google.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=netdev@vger.kernel.org \
--cc=sathya.perla@broadcom.com \
--cc=somnath.kotur@broadcom.com \
--cc=sriharsha.basavapatna@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).