netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Leon Romanovsky' <leon@kernel.org>
Cc: Anand Khoje <anand.a.khoje@oracle.com>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"saeedm@mellanox.com" <saeedm@mellanox.com>,
	"tariqt@nvidia.com" <tariqt@nvidia.com>,
	"edumazet@google.com" <edumazet@google.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: RE: [PATCH v4] net/mlx5: Reclaim max 50K pages at once
Date: Mon, 15 Jul 2024 08:22:19 +0000	[thread overview]
Message-ID: <c702670609914da89e934879b5c89de7@AcuMS.aculab.com> (raw)
In-Reply-To: <20240701114949.GB13195@unreal>

From: Leon Romanovsky
> Sent: 01 July 2024 12:50
> To: David Laight <David.Laight@ACULAB.COM>
...
> > > BTW, this can be written as:
> > > 	req->npages = max_t(s32, npages, MAX_RECLAIM_NPAGES);
> >
> > That shouldn't need all the (s32) casts.
> 
> #define doesn't have a type, so it is better to be explicit here.

The constant has a type, the cast just hides any checking that might be done.
Would you really write:
	if ((s32)npages > (s32)-50000)
		...
Because that is what you are generating.

Here it probably doesn't matter, but it is really bad practise.
If, for example, 'npages' is 64 bit than the cast can change the value.

There are places where the type of the result has been used and caused
bugs because a value got masked to 16 bits.

In reality there should be a big trawl through the code to try to
remove all the 'pointless' min_t() and max_t().
Adding new ones just makes it worse.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

  reply	other threads:[~2024-07-15  8:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-19 13:28 [PATCH v4] net/mlx5: Reclaim max 50K pages at once Anand Khoje
2024-06-24  9:57 ` Leon Romanovsky
2024-06-24 15:48   ` Anand Khoje
2024-06-28 15:13   ` David Laight
2024-07-01 11:49     ` Leon Romanovsky
2024-07-15  8:22       ` David Laight [this message]
2024-07-15 10:23         ` Leon Romanovsky

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=c702670609914da89e934879b5c89de7@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=anand.a.khoje@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@mellanox.com \
    --cc=tariqt@nvidia.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).