mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-16 10:20:30 +00:00
Limit mbuma damage. Suddenly ALL allocations with M_WAITOK are subject
to failing -- that is, allocations via malloc(M_WAITOK) that are required to never fail -- if WITNESS is not defined. While everyone should be running WITNESS, in any case, zone "Mbuf" allocations are really the only ones that should be screwed with by this hack. This hack is crashing people, and would continue to do so with or without WITNESS. Things shouldn't be allocating with M_WAITOK with locks held, but it's not okay just to always remove M_WAITOK when !WITNESS. Reported by: Bernd Walter <ticso@cicely5.cicely.de>
This commit is contained in:
parent
279f949ee5
commit
cf107c1d1a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=131528
@ -1603,7 +1603,7 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
|
||||
uma_cache_t cache;
|
||||
uma_bucket_t bucket;
|
||||
int cpu;
|
||||
int badness = 1;
|
||||
int badness = 0;
|
||||
|
||||
/* This is the fast path allocation */
|
||||
#ifdef UMA_DEBUG_ALLOC_1
|
||||
@ -1613,10 +1613,14 @@ uma_zalloc_arg(uma_zone_t zone, void *udata, int flags)
|
||||
if (!(flags & M_NOWAIT)) {
|
||||
KASSERT(curthread->td_intr_nesting_level == 0,
|
||||
("malloc(M_WAITOK) in interrupt context"));
|
||||
if (strcmp(zone->uz_name, "Mbuf") == 0)
|
||||
#ifdef WITNESS
|
||||
badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL,
|
||||
"malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
|
||||
zone->uz_name);
|
||||
badness = WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK,
|
||||
NULL,
|
||||
"malloc(M_WAITOK) of \"%s\", forcing M_NOWAIT",
|
||||
zone->uz_name);
|
||||
#else
|
||||
badness = 1;
|
||||
#endif
|
||||
if (badness) {
|
||||
flags &= ~M_WAITOK;
|
||||
|
Loading…
Reference in New Issue
Block a user