mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Gur Stavi <gur.stavi@huawei.com>
To: <lulie@linux.alibaba.com>
Cc: <antony.antony@secunet.com>, <davem@davemloft.net>,
	<dsahern@kernel.org>, <dust.li@linux.alibaba.com>,
	<edumazet@google.com>, <fred.cc@alibaba-inc.com>,
	<jakub@cloudflare.com>, <kuba@kernel.org>,
	<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
	<pabeni@redhat.com>, <steffen.klassert@secunet.com>,
	<willemdebruijn.kernel@gmail.com>,
	<yubing.qiuyubing@alibaba-inc.com>
Subject: [RFC PATCHv2 net-next 1/3] net/udp: Add a new struct for hash2 slot
Date: Tue, 24 Sep 2024 15:30:17 +0300	[thread overview]
Message-ID: <20240924123017.1688277-1-gur.stavi@huawei.com> (raw)
In-Reply-To: <20240924110414.52618-2-lulie@linux.alibaba.com>

> + *	@hslot:	basic hash slot
> + *	@hash4_cnt: number of sockets in hslot4 of the same (local port, local address)
> + */
> +struct udp_hslot_main {
> +	struct udp_hslot	hslot; /* must be the first member */
> +	u32			hash4_cnt;
> +} __aligned(2 * sizeof(long));
> +#define UDP_HSLOT_MAIN(__hslot) ((struct udp_hslot_main *)(__hslot))

Wouldn't container_of be more suitable than brutal cast?

> @@ -91,7 +110,7 @@ static inline struct udp_hslot *udp_hashslot(struct udp_table *table,
>  static inline struct udp_hslot *udp_hashslot2(struct udp_table *table,
>  					      unsigned int hash)
>  {
> -	return &table->hash2[hash & table->mask];
> +	return (struct udp_hslot *)udp_hashslot2_main(table, hash);

Why cast and not use ->hslot. Preferably with a local variable?

> @@ -3438,16 +3436,17 @@ void __init udp_table_init(struct udp_table *table, const char *name)
>  					      UDP_HTABLE_SIZE_MIN,
>  					      UDP_HTABLE_SIZE_MAX);
>
> -	table->hash2 = table->hash + (table->mask + 1);
> +	table->hash2 = UDP_HSLOT_MAIN(table->hash + (table->mask + 1));

Wouldn't it be simpler to just cast to void? It is pure pointer
arithmetic where type checking is meaningless.
(void *)(table->hash + (table->mask + 1))
I realize now why UDP_HSLOT_MAIN couldn't use container_of but it
just demonstrates how convoluted this is.


  reply	other threads:[~2024-09-24 12:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-24 11:04 [RFC PATCHv2 net-next 0/3] udp: Add 4-tuple hash for connected sockets Philo Lu
2024-09-24 11:04 ` [RFC PATCHv2 net-next 1/3] net/udp: Add a new struct for hash2 slot Philo Lu
2024-09-24 12:30   ` Gur Stavi [this message]
2024-09-25  2:43     ` Philo Lu
2024-09-24 12:51   ` Gur Stavi
2024-09-25  2:57     ` Philo Lu
2024-09-24 11:04 ` [RFC PATCHv2 net-next 2/3] net/udp: Add 4-tuple hash list basis Philo Lu
2024-09-24 11:04 ` [RFC PATCHv2 net-next 3/3] ipv4/udp: Add 4-tuple hash for connected socket Philo Lu
2024-09-24 12:31   ` Gur Stavi
2024-09-25  3:16     ` Philo Lu

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=20240924123017.1688277-1-gur.stavi@huawei.com \
    --to=gur.stavi@huawei.com \
    --cc=antony.antony@secunet.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=fred.cc@alibaba-inc.com \
    --cc=jakub@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lulie@linux.alibaba.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=steffen.klassert@secunet.com \
    --cc=willemdebruijn.kernel@gmail.com \
    --cc=yubing.qiuyubing@alibaba-inc.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

all inboxes | Powered by JetHome®