RE: [PATCH v4] net/mlx5: Reclaim max 50K pages at once

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Leon Romanovsky
> Sent: 01 July 2024 12:50
> To: David Laight <David.Laight@xxxxxxxxxx>
...
> > > 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)




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux