Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F133043347
D2165.id4489.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D2165.id4489.diff
View Options
Index: sys/rpc/svc.h
===================================================================
--- sys/rpc/svc.h
+++ sys/rpc/svc.h
@@ -371,10 +371,10 @@
* amount of memory used by RPC requests which are queued
* waiting for execution.
*/
- unsigned int sp_space_low;
- unsigned int sp_space_high;
- unsigned int sp_space_used;
- unsigned int sp_space_used_highest;
+ unsigned long sp_space_low;
+ unsigned long sp_space_high;
+ unsigned long sp_space_used;
+ unsigned long sp_space_used_highest;
bool_t sp_space_throttled;
int sp_space_throttle_count;
Index: sys/rpc/svc.c
===================================================================
--- sys/rpc/svc.c
+++ sys/rpc/svc.c
@@ -73,7 +73,7 @@
char *);
static void svc_new_thread(SVCGROUP *grp);
static void xprt_unregister_locked(SVCXPRT *xprt);
-static void svc_change_space_used(SVCPOOL *pool, int delta);
+static void svc_change_space_used(SVCPOOL *pool, long delta);
static bool_t svc_request_space_available(SVCPOOL *pool);
/* *************** SVCXPRT related stuff **************** */
@@ -113,12 +113,14 @@
}
/*
- * Don't use more than a quarter of mbuf clusters or more than
- * 45Mb buffering requests.
+ * Don't use more than a quarter of mbuf clusters. On ILP32
+ * platforms, avoid integer overflow even if a silly value
+ * of nmbclusters is configured.
*/
- pool->sp_space_high = nmbclusters * MCLBYTES / 4;
- if (pool->sp_space_high > 45 << 20)
- pool->sp_space_high = 45 << 20;
+ if (nmbclusters > LONG_MAX / MCLBYTES)
+ pool->sp_space_high = LONG_MAX / 4;
+ else
+ pool->sp_space_high = (long)nmbclusters * MCLBYTES / 4;
pool->sp_space_low = 2 * pool->sp_space_high / 3;
sysctl_ctx_init(&pool->sp_sysctl);
@@ -139,24 +141,24 @@
"groups", CTLFLAG_RD, &pool->sp_groupcount, 0,
"Number of thread groups");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_used", CTLFLAG_RD,
- &pool->sp_space_used, 0,
+ &pool->sp_space_used,
"Space in parsed but not handled requests.");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_used_highest", CTLFLAG_RD,
- &pool->sp_space_used_highest, 0,
+ &pool->sp_space_used_highest,
"Highest space used since reboot.");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_high", CTLFLAG_RW,
- &pool->sp_space_high, 0,
+ &pool->sp_space_high,
"Maximum space in parsed but not handled requests.");
- SYSCTL_ADD_UINT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
+ SYSCTL_ADD_ULONG(&pool->sp_sysctl, sysctl_base, OID_AUTO,
"request_space_low", CTLFLAG_RW,
- &pool->sp_space_low, 0,
+ &pool->sp_space_low,
"Low water mark for request space.");
SYSCTL_ADD_INT(&pool->sp_sysctl, sysctl_base, OID_AUTO,
@@ -1064,11 +1066,11 @@
}
static void
-svc_change_space_used(SVCPOOL *pool, int delta)
+svc_change_space_used(SVCPOOL *pool, long delta)
{
- unsigned int value;
+ unsigned long value;
- value = atomic_fetchadd_int(&pool->sp_space_used, delta) + delta;
+ value = atomic_fetchadd_long(&pool->sp_space_used, delta) + delta;
if (delta > 0) {
if (value >= pool->sp_space_high && !pool->sp_space_throttled) {
pool->sp_space_throttled = TRUE;
@@ -1101,7 +1103,6 @@
SVCXPRT *xprt;
enum xprt_stat stat;
struct svc_req *rqstp;
- size_t sz;
int error;
st = mem_alloc(sizeof(*st));
@@ -1246,17 +1247,15 @@
/*
* Execute what we have queued.
*/
- sz = 0;
mtx_lock(&st->st_lock);
while ((rqstp = STAILQ_FIRST(&st->st_reqs)) != NULL) {
STAILQ_REMOVE_HEAD(&st->st_reqs, rq_link);
mtx_unlock(&st->st_lock);
- sz += rqstp->rq_size;
svc_executereq(rqstp);
+ svc_change_space_used(pool, -(long)rqstp->rq_size);
mtx_lock(&st->st_lock);
}
mtx_unlock(&st->st_lock);
- svc_change_space_used(pool, -sz);
mtx_lock(&grp->sg_lock);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Oct 23, 9:41 AM (14 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24088300
Default Alt Text
D2165.id4489.diff (4 KB)
Attached To
Mode
D2165: Remove antique hard-coded limit and integer overflow bugs in kernel RPC request throttling code
Attached
Detach File
Event Timeline
Log In to Comment