diff mbox series

igb: cope with large MAX_SKB_FRAGS.

Message ID 20240423102446.901450-1-vinschen@redhat.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series igb: cope with large MAX_SKB_FRAGS. | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 926 this patch: 926
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 4 blamed authors not CCed: kuba@kernel.org edumazet@google.com kerneljasonxing@gmail.com razor@blackwall.org; 7 maintainers not CCed: pabeni@redhat.com anthony.l.nguyen@intel.com edumazet@google.com kerneljasonxing@gmail.com razor@blackwall.org kuba@kernel.org jesse.brandeburg@intel.com
netdev/build_clang success Errors and warnings before: 937 this patch: 937
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 937 this patch: 937
netdev/checkpatch warning WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAGS")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 38 this patch: 38
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-24--15-00 (tests: 995)

Commit Message

Corinna Vinschen April 23, 2024, 10:24 a.m. UTC
From: Paolo Abeni <pabeni@redhat.com>

Sabrina reports that the igb driver does not cope well with large
MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
corruption on TX.

The root cause of the issue is that the driver does not take into
account properly the (possibly large) shared info size when selecting
the ring layout, and will try to fit two packets inside the same 4K
page even when the 1st fraglist will trump over the 2nd head.

Address the issue forcing the driver to fit a single packet per page,
leaving there enough room to store the (currently) largest possible
skb_shared_info.

Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAG")
Reported-by: Jan Tluka <jtluka@redhat.com>
Reported-by: Jirka Hladky <jhladky@redhat.com>
Reported-by: Sabrina Dubroca <sd@queasysnail.net>
Tested-by: Sabrina Dubroca <sd@queasysnail.net>
Tested-by: Corinna Vinschen <vinschen@redhat.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 drivers/net/ethernet/intel/igb/igb_main.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jiri Pirko April 23, 2024, 11:25 a.m. UTC | #1
Tue, Apr 23, 2024 at 12:24:46PM CEST, vinschen@redhat.com wrote:
>From: Paolo Abeni <pabeni@redhat.com>
>
>Sabrina reports that the igb driver does not cope well with large
>MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
>corruption on TX.
>
>The root cause of the issue is that the driver does not take into
>account properly the (possibly large) shared info size when selecting
>the ring layout, and will try to fit two packets inside the same 4K
>page even when the 1st fraglist will trump over the 2nd head.
>
>Address the issue forcing the driver to fit a single packet per page,
>leaving there enough room to store the (currently) largest possible
>skb_shared_info.
>
>Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAG")
>Reported-by: Jan Tluka <jtluka@redhat.com>
>Reported-by: Jirka Hladky <jhladky@redhat.com>
>Reported-by: Sabrina Dubroca <sd@queasysnail.net>
>Tested-by: Sabrina Dubroca <sd@queasysnail.net>
>Tested-by: Corinna Vinschen <vinschen@redhat.com>
>Signed-off-by: Paolo Abeni <pabeni@redhat.com>

Reviewed-by: Jiri Pirko <jiri@nvidia.com>

Next time, please indicate target tree (net) in [patch] brackets.


>---
> drivers/net/ethernet/intel/igb/igb_main.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
>index a3f100769e39..22fb2c322bca 100644
>--- a/drivers/net/ethernet/intel/igb/igb_main.c
>+++ b/drivers/net/ethernet/intel/igb/igb_main.c
>@@ -4833,6 +4833,7 @@ static void igb_set_rx_buffer_len(struct igb_adapter *adapter,
> 
> #if (PAGE_SIZE < 8192)
> 	if (adapter->max_frame_size > IGB_MAX_FRAME_BUILD_SKB ||
>+	    SKB_HEAD_ALIGN(adapter->max_frame_size) > (PAGE_SIZE / 2) ||
> 	    rd32(E1000_RCTL) & E1000_RCTL_SBP)
> 		set_ring_uses_large_buffer(rx_ring);
> #endif
>-- 
>2.44.0
>
>
Jiri Pirko April 23, 2024, 11:26 a.m. UTC | #2
Tue, Apr 23, 2024 at 12:24:46PM CEST, vinschen@redhat.com wrote:
>From: Paolo Abeni <pabeni@redhat.com>
>
>Sabrina reports that the igb driver does not cope well with large
>MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
>corruption on TX.
>
>The root cause of the issue is that the driver does not take into
>account properly the (possibly large) shared info size when selecting
>the ring layout, and will try to fit two packets inside the same 4K
>page even when the 1st fraglist will trump over the 2nd head.
>
>Address the issue forcing the driver to fit a single packet per page,
>leaving there enough room to store the (currently) largest possible
>skb_shared_info.
>
>Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAG")
>Reported-by: Jan Tluka <jtluka@redhat.com>
>Reported-by: Jirka Hladky <jhladky@redhat.com>
>Reported-by: Sabrina Dubroca <sd@queasysnail.net>
>Tested-by: Sabrina Dubroca <sd@queasysnail.net>
>Tested-by: Corinna Vinschen <vinschen@redhat.com>
>Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>---
> drivers/net/ethernet/intel/igb/igb_main.c | 1 +

Also, please use get_maintainer.pl script to get cclist.
Paul Menzel April 23, 2024, 11:52 a.m. UTC | #3
Dear Corinna,


Thank you for the patch.


Am 23.04.24 um 12:24 schrieb Corinna Vinschen:
> From: Paolo Abeni <pabeni@redhat.com>

It’d be great if you removed the trailing dot/period in the commit 
message summary.

> Sabrina reports that the igb driver does not cope well with large
> MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
> corruption on TX.
> 
> The root cause of the issue is that the driver does not take into
> account properly the (possibly large) shared info size when selecting
> the ring layout, and will try to fit two packets inside the same 4K
> page even when the 1st fraglist will trump over the 2nd head.
> 
> Address the issue forcing the driver to fit a single packet per page,
> leaving there enough room to store the (currently) largest possible
> skb_shared_info.

If you have a reproducer for this, it’d be great if you could document 
it in the commit message.

> Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAG")
> Reported-by: Jan Tluka <jtluka@redhat.com>
> Reported-by: Jirka Hladky <jhladky@redhat.com>
> Reported-by: Sabrina Dubroca <sd@queasysnail.net>
> Tested-by: Sabrina Dubroca <sd@queasysnail.net>
> Tested-by: Corinna Vinschen <vinschen@redhat.com>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> ---
>   drivers/net/ethernet/intel/igb/igb_main.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index a3f100769e39..22fb2c322bca 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -4833,6 +4833,7 @@ static void igb_set_rx_buffer_len(struct igb_adapter *adapter,
>   
>   #if (PAGE_SIZE < 8192)
>   	if (adapter->max_frame_size > IGB_MAX_FRAME_BUILD_SKB ||
> +	    SKB_HEAD_ALIGN(adapter->max_frame_size) > (PAGE_SIZE / 2) ||
>   	    rd32(E1000_RCTL) & E1000_RCTL_SBP)
>   		set_ring_uses_large_buffer(rx_ring);
>   #endif


Kind regards,

Paul
Corinna Vinschen April 23, 2024, 1:52 p.m. UTC | #4
Hi Paul,

On Apr 23 13:52, Paul Menzel wrote:
> Dear Corinna,
> 
> 
> Thank you for the patch.
> 
> 
> Am 23.04.24 um 12:24 schrieb Corinna Vinschen:
> > From: Paolo Abeni <pabeni@redhat.com>
> 
> It’d be great if you removed the trailing dot/period in the commit message
> summary.
> 
> > Sabrina reports that the igb driver does not cope well with large
> > MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
> > corruption on TX.
> > 
> > The root cause of the issue is that the driver does not take into
> > account properly the (possibly large) shared info size when selecting
> > the ring layout, and will try to fit two packets inside the same 4K
> > page even when the 1st fraglist will trump over the 2nd head.
> > 
> > Address the issue forcing the driver to fit a single packet per page,
> > leaving there enough room to store the (currently) largest possible
> > skb_shared_info.
> 
> If you have a reproducer for this, it’d be great if you could document it in
> the commit message.

I fixed the trailing dot and added a reproducer.

Thanks,
Corinna
Corinna Vinschen April 23, 2024, 1:54 p.m. UTC | #5
Hi Jiri,

On Apr 23 13:26, Jiri Pirko wrote:
> Tue, Apr 23, 2024 at 12:24:46PM CEST, vinschen@redhat.com wrote:
> >From: Paolo Abeni <pabeni@redhat.com>
> >
> >Sabrina reports that the igb driver does not cope well with large
> >MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
> >corruption on TX.
> >
> >The root cause of the issue is that the driver does not take into
> >account properly the (possibly large) shared info size when selecting
> >the ring layout, and will try to fit two packets inside the same 4K
> >page even when the 1st fraglist will trump over the 2nd head.
> >
> >Address the issue forcing the driver to fit a single packet per page,
> >leaving there enough room to store the (currently) largest possible
> >skb_shared_info.
> >
> >Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAG")
> >Reported-by: Jan Tluka <jtluka@redhat.com>
> >Reported-by: Jirka Hladky <jhladky@redhat.com>
> >Reported-by: Sabrina Dubroca <sd@queasysnail.net>
> >Tested-by: Sabrina Dubroca <sd@queasysnail.net>
> >Tested-by: Corinna Vinschen <vinschen@redhat.com>
> >Signed-off-by: Paolo Abeni <pabeni@redhat.com>
> >---
> > drivers/net/ethernet/intel/igb/igb_main.c | 1 +
> 
> Also, please use get_maintainer.pl script to get cclist.

done and done in v2 (for which I forgot the "in-reply-to" now, d'uh)

Thanks,
Corinna
Jiri Pirko April 23, 2024, 3:30 p.m. UTC | #6
Tue, Apr 23, 2024 at 03:54:05PM CEST, vinschen@redhat.com wrote:
>Hi Jiri,
>
>On Apr 23 13:26, Jiri Pirko wrote:
>> Tue, Apr 23, 2024 at 12:24:46PM CEST, vinschen@redhat.com wrote:
>> >From: Paolo Abeni <pabeni@redhat.com>
>> >
>> >Sabrina reports that the igb driver does not cope well with large
>> >MAX_SKB_FRAG values: setting MAX_SKB_FRAG to 45 causes payload
>> >corruption on TX.
>> >
>> >The root cause of the issue is that the driver does not take into
>> >account properly the (possibly large) shared info size when selecting
>> >the ring layout, and will try to fit two packets inside the same 4K
>> >page even when the 1st fraglist will trump over the 2nd head.
>> >
>> >Address the issue forcing the driver to fit a single packet per page,
>> >leaving there enough room to store the (currently) largest possible
>> >skb_shared_info.
>> >
>> >Fixes: 3948b05950fd ("net: introduce a config option to tweak MAX_SKB_FRAG")
>> >Reported-by: Jan Tluka <jtluka@redhat.com>
>> >Reported-by: Jirka Hladky <jhladky@redhat.com>
>> >Reported-by: Sabrina Dubroca <sd@queasysnail.net>
>> >Tested-by: Sabrina Dubroca <sd@queasysnail.net>
>> >Tested-by: Corinna Vinschen <vinschen@redhat.com>
>> >Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>> >---
>> > drivers/net/ethernet/intel/igb/igb_main.c | 1 +
>> 
>> Also, please use get_maintainer.pl script to get cclist.
>
>done and done in v2 (for which I forgot the "in-reply-to" now, d'uh)

In-reply-to is not needed. Send each V to separate thread.

>
>Thanks,
>Corinna
>
>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
index a3f100769e39..22fb2c322bca 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -4833,6 +4833,7 @@  static void igb_set_rx_buffer_len(struct igb_adapter *adapter,
 
 #if (PAGE_SIZE < 8192)
 	if (adapter->max_frame_size > IGB_MAX_FRAME_BUILD_SKB ||
+	    SKB_HEAD_ALIGN(adapter->max_frame_size) > (PAGE_SIZE / 2) ||
 	    rd32(E1000_RCTL) & E1000_RCTL_SBP)
 		set_ring_uses_large_buffer(rx_ring);
 #endif