mirror of
https://git.FreeBSD.org/src.git
synced 2025-02-01 17:00:36 +00:00
Rewrote the space check algorithm in sbreserve() so that the extremely
expensive (!) 64bit multiply, divide, and comparison aren't necessary (this came in originally from rev 1.19 to fix an overflow with large sb_max or MCLBYTES). The 64bit math in this function was measured in some kernel profiles as being as much as 5-8% of the total overhead of the TCP/IP stack and is eliminated with this commit. There is a harmless rounding error (of about .4% with the standard values) introduced with this change, however this is in the conservative direction (downward toward a slightly smaller maximum socket buffer size). MFC after: 3 days
This commit is contained in:
parent
19c99159d4
commit
8c71ce8a4e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=101966
@ -392,7 +392,7 @@ sbreserve(sb, cc, so, td)
|
||||
* td will only be NULL when we're in an interrupt
|
||||
* (e.g. in tcp_input())
|
||||
*/
|
||||
if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
|
||||
if (cc > sb_max / (MSIZE + MCLBYTES) * MCLBYTES)
|
||||
return (0);
|
||||
if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc,
|
||||
td ? td->td_proc->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) {
|
||||
|
@ -392,7 +392,7 @@ sbreserve(sb, cc, so, td)
|
||||
* td will only be NULL when we're in an interrupt
|
||||
* (e.g. in tcp_input())
|
||||
*/
|
||||
if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES))
|
||||
if (cc > sb_max / (MSIZE + MCLBYTES) * MCLBYTES)
|
||||
return (0);
|
||||
if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc,
|
||||
td ? td->td_proc->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) {
|
||||
|
Loading…
Reference in New Issue
Block a user