netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rémi Denis-Courmont" <remi@remlab.net>
To: Lin Zhang <xiaolou4617@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org, courmisch@gmail.com
Subject: Re: [PATCH v2 2/2] net: phonet: mark phonet_protocol as const
Date: Sat, 30 Sep 2017 14:51:49 +0300	[thread overview]
Message-ID: <1640482.VEeSHCmrEB@philogene> (raw)
In-Reply-To: <1506764448-6915-1-git-send-email-xiaolou4617@gmail.com>

On samedi 30 septembre 2017 17:40:48 EEST Lin Zhang wrote:
> The phonet_protocol structs don't need to be written by anyone and
> so can be marked as const.
> 
> Signed-off-by: Lin Zhang <xiaolou4617@gmail.com>
> ---
> changelog:
> 
> v1 -> v2:
> 	* remove __read_mostly tag
> ---
>  include/net/phonet/phonet.h |  6 ++++--
>  net/phonet/af_phonet.c      | 15 ++++++++-------
>  net/phonet/datagram.c       |  2 +-
>  net/phonet/pep.c            |  2 +-
>  4 files changed, 14 insertions(+), 11 deletions(-)
> 
> diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h
> index 039cc29..51e1a2a 100644
> --- a/include/net/phonet/phonet.h
> +++ b/include/net/phonet/phonet.h
> @@ -108,8 +108,10 @@ struct phonet_protocol {
>  	int			sock_type;
>  };
> 
> -int phonet_proto_register(unsigned int protocol, struct phonet_protocol
> *pp); -void phonet_proto_unregister(unsigned int protocol, struct
> phonet_protocol *pp); +int phonet_proto_register(unsigned int protocol,
> +		const struct phonet_protocol *pp);
> +void phonet_proto_unregister(unsigned int protocol,
> +		const struct phonet_protocol *pp);
> 
>  int phonet_sysctl_init(void);
>  void phonet_sysctl_exit(void);
> diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
> index b12142e..63b9870 100644
> --- a/net/phonet/af_phonet.c
> +++ b/net/phonet/af_phonet.c
> @@ -35,11 +35,11 @@
>  #include <net/phonet/pn_dev.h>
> 
>  /* Transport protocol registration */
> -static struct phonet_protocol *proto_tab[PHONET_NPROTO] __read_mostly;
> +static const struct phonet_protocol *proto_tab[PHONET_NPROTO];

Your patch makes each element in the table constant. It does not, cannot, make 
the table itself constant. So I am not certain that removing __read_mostly is 
a good thing.

(Well, nowadays this should probably be rare-write rather than read-mostly but 
that's a slightly different issue.)

-- 
Rémi Denis-Courmont

      reply	other threads:[~2017-09-30 12:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30  9:40 [PATCH v2 2/2] net: phonet: mark phonet_protocol as const Lin Zhang
2017-09-30 11:51 ` Rémi Denis-Courmont [this message]

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=1640482.VEeSHCmrEB@philogene \
    --to=remi@remlab.net \
    --cc=courmisch@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xiaolou4617@gmail.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).