From: Paolo Abeni <pabeni@redhat.com>
To: Ido Schimmel <idosch@nvidia.com>, WangYuli <wangyuli@uniontech.com>
Cc: andrew+netdev@lunn.ch, chenlinxuan@uniontech.com,
czj2441@163.com, davem@davemloft.net, edumazet@google.com,
guanwentao@uniontech.com, kuba@kernel.org,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
niecheng1@uniontech.com, petrm@nvidia.com, zhanjun@uniontech.com
Subject: Re: [PATCH net 1/2] mlxsw: spectrum_acl_bloom_filter: Expand chunk_key_offsets[chunk_index]
Date: Thu, 13 Mar 2025 14:52:11 +0100 [thread overview]
Message-ID: <70a2fa44-c0cf-4dd4-8c17-8cc7abf1fbce@redhat.com> (raw)
In-Reply-To: <Z9GKE-mP3qbmK9cL@shredder>
On 3/12/25 2:20 PM, Ido Schimmel wrote:
> On Tue, Mar 11, 2025 at 10:17:00PM +0800, WangYuli wrote:
>> This is a workaround to mitigate a compiler anomaly.
>>
>> During LLVM toolchain compilation of this driver on s390x architecture, an
>> unreasonable __write_overflow_field warning occurs.
>>
>> Contextually, chunk_index is restricted to 0, 1 or 2. By expanding these
>> possibilities, the compile warning is suppressed.
>
> I'm not sure why the fix suppresses the warning when the warning is
> about the destination buffer and the fix is about the source. Can you
> check if the below helps? It removes the parameterization from
> __mlxsw_sp_acl_bf_key_encode() and instead splits it to two variants.
>
> diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c
> index a54eedb69a3f..3e1e4be72da2 100644
> --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c
> +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl_bloom_filter.c
> @@ -110,7 +110,6 @@ static const u16 mlxsw_sp2_acl_bf_crc16_tab[256] = {
> * +-----------+----------+-----------------------------------+
> */
>
> -#define MLXSW_SP4_BLOOM_CHUNK_PAD_BYTES 0
> #define MLXSW_SP4_BLOOM_CHUNK_KEY_BYTES 18
> #define MLXSW_SP4_BLOOM_KEY_CHUNK_BYTES 20
>
> @@ -229,10 +228,9 @@ static u16 mlxsw_sp2_acl_bf_crc(const u8 *buffer, size_t len)
> }
>
> static void
> -__mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion,
> - struct mlxsw_sp_acl_atcam_entry *aentry,
> - char *output, u8 *len, u8 max_chunks, u8 pad_bytes,
> - u8 key_offset, u8 chunk_key_len, u8 chunk_len)
> +mlxsw_sp2_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion,
> + struct mlxsw_sp_acl_atcam_entry *aentry,
> + char *output, u8 *len)
> {
> struct mlxsw_afk_key_info *key_info = aregion->region->key_info;
> u8 chunk_index, chunk_count, block_count;
> @@ -243,30 +241,17 @@ __mlxsw_sp_acl_bf_key_encode(struct mlxsw_sp_acl_atcam_region *aregion,
> chunk_count = 1 + ((block_count - 1) >> 2);
> erp_region_id = cpu_to_be16(aentry->ht_key.erp_id |
> (aregion->region->id << 4));
> - for (chunk_index = max_chunks - chunk_count; chunk_index < max_chunks;
> - chunk_index++) {
> - memset(chunk, 0, pad_bytes);
> - memcpy(chunk + pad_bytes, &erp_region_id,
> + for (chunk_index = MLXSW_BLOOM_KEY_CHUNKS - chunk_count;
> + chunk_index < MLXSW_BLOOM_KEY_CHUNKS; chunk_index++) {
Possibly the compiler is inferring chunck count can be greater then
MLXSW_BLOOM_KEY_CHUNKS?
something alike:
chunk_index = min_t(0, MLXSW_BLOOM_KEY_CHUNKS - chunk_count, u8);
Could possibly please it?
/P
next prev parent reply other threads:[~2025-03-13 13:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 14:10 [PATCH net 0/2] mlxsw: spectrum_acl_bloom_filter: Fix compilation warning on s390x WangYuli
2025-03-11 14:17 ` [PATCH net 1/2] mlxsw: spectrum_acl_bloom_filter: Expand chunk_key_offsets[chunk_index] WangYuli
2025-03-12 13:20 ` Ido Schimmel
2025-03-13 8:52 ` WangYuli
2025-03-13 13:52 ` Paolo Abeni [this message]
2025-03-13 15:25 ` Ido Schimmel
2025-03-13 16:10 ` WangYuli
2025-03-13 19:41 ` Ido Schimmel
2025-03-14 18:10 ` WangYuli
2025-03-13 13:54 ` Paolo Abeni
2025-03-11 14:17 ` [PATCH net 2/2] mlxsw: spectrum_acl_bloom_filter: Type block_count to u32 WangYuli
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=70a2fa44-c0cf-4dd4-8c17-8cc7abf1fbce@redhat.com \
--to=pabeni@redhat.com \
--cc=andrew+netdev@lunn.ch \
--cc=chenlinxuan@uniontech.com \
--cc=czj2441@163.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=guanwentao@uniontech.com \
--cc=idosch@nvidia.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=niecheng1@uniontech.com \
--cc=petrm@nvidia.com \
--cc=wangyuli@uniontech.com \
--cc=zhanjun@uniontech.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®