Skip to content

Commit

Permalink
14198 stack overflow from promisc callbacks
Browse files Browse the repository at this point in the history
Reviewed by: Yuri Pankov <ypankov@tintri.com>
Reviewed by: Gordon Ross <Gordon.W.Ross@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
rmustacc authored and citrus-it committed Nov 30, 2021
1 parent d1c0264 commit f1b92f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
15 changes: 11 additions & 4 deletions usr/src/uts/common/disp/thread_intr.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright 2015, Joyent, Inc.
*/

#include <sys/cpuvar.h>
#include <sys/stack.h>
#include <vm/seg_kp.h>
#include <sys/machparam.h>
#include <sys/proc.h>
#include <sys/pset.h>
#include <sys/sysmacros.h>
Expand All @@ -39,7 +43,7 @@ thread_create_intr(cpu_t *cp)
{
kthread_t *tp;

tp = thread_create(NULL, 0,
tp = thread_create(NULL, LL_INTR_STKSZ,
(void (*)())thread_create_intr, NULL, 0, &p0, TS_ONPROC, 0);

/*
Expand Down Expand Up @@ -85,9 +89,12 @@ thread_create_intr(cpu_t *cp)
}

/*
* Allocate a given number of interrupt threads for a given CPU.
* These threads will get freed by cpu_destroy_bound_threads()
* when CPU gets unconfigured.
* Allocate a given number of interrupt threads for a given CPU. These threads
* will get freed by cpu_destroy_bound_threads() when the CPU gets unconfigured.
*
* Note, high level interrupts are always serviced using cpu_intr_stack and are
* not allowed to block. Low level interrupts or soft-interrupts use the
* kthread_t's that we create through the calls to thread_create_intr().
*/
void
cpu_intr_alloc(cpu_t *cp, int n)
Expand Down
14 changes: 13 additions & 1 deletion usr/src/uts/i86pc/sys/machparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extern "C" {
* The value defined below could grow to 16. hat structure and
* page_t have room for 16 nodes.
*/
#define MAXNODES 4
#define MAXNODES 4
#define NUMA_NODEMASK 0x0f

/*
Expand Down Expand Up @@ -120,6 +120,18 @@ extern "C" {
#define DEFAULTSTKSZ _MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
#endif /* !_ASM */

/*
* Use a slightly larger thread stack size for interrupt threads rather than
* the default. This is useful for cases where the networking stack may do an
* rx and a tx in the context of a single interrupt and when combined with
* various promisc hooks that need memory, can cause us to get dangerously
* close to the edge of the traditional stack sizes. This is only a few pages
* more than a traditional stack and given that we don't have that many
* interrupt threads, the memory costs end up being more than worthwhile.
*/
#define LL_INTR_STKSZ_NPGS 8
#define LL_INTR_STKSZ (LL_INTR_STKSZ_NPGS * PAGESIZE)

/*
* During intial boot we limit heap to the top 4Gig.
*/
Expand Down

0 comments on commit f1b92f9

Please sign in to comment.