FreeBSD/sys/net/netisr.c
/*
 * Sysctl monitoring for netisr: query a list of workstreams.
 */
Sysctl monitoring for netisr: query a list of workstreams.
Sysctl monitoring for netisr : query a list of workstreams .
static int
sysctl_netisr_workstream(SYSCTL_HANDLER_ARGS)
{
	struct rm_priotracker tracker;
	struct sysctl_netisr_workstream *snwsp, *snws_array;
	struct netisr_workstream *nwsp;
	u_int counter, cpuid;
	int error;
	if (req->newptr != NULL)
		return (EINVAL);
	snws_array = malloc(sizeof(*snws_array) * MAXCPU, M_TEMP,
	    M_ZERO | M_WAITOK);
	counter = 0;
	NETISR_RLOCK(&tracker);
	CPU_FOREACH(cpuid) {
		nwsp = DPCPU_ID_PTR(cpuid, nws);
		if (nwsp->nws_intr_event == NULL)
			continue;
		NWS_LOCK(nwsp);
		snwsp = &snws_array[counter];
		snwsp->snws_version = sizeof(*snwsp);
		snwsp->snws_wsid = cpuid;
		snwsp->snws_cpu = cpuid;
		if (nwsp->nws_intr_event != NULL)
			snwsp->snws_flags |= NETISR_SNWS_FLAGS_INTR;
		NWS_UNLOCK(nwsp);
		counter++;
	}
	NETISR_RUNLOCK(&tracker);
	KASSERT(counter <= MAXCPU,
	    ("sysctl_netisr_workstream: counter too big (%d)", counter));
	error = SYSCTL_OUT(req, snws_array, sizeof(*snws_array) * counter);
	free(snws_array, M_TEMP);
	return (error);
}
static int sysctl_netisr_workstream ( SYSCTL_HANDLER_ARGS ) { struct rm_priotracker tracker ; struct sysctl_netisr_workstream * snwsp , * snws_array ; struct netisr_workstream * nwsp ; u_int counter , cpuid ; int error ; if ( req -> newptr != NULL ) return ( EINVAL ) ; snws_array = malloc ( sizeof ( * snws_array ) * MAXCPU , M_TEMP , M_ZERO | M_WAITOK ) ; counter = 0 ; NETISR_RLOCK ( & tracker ) ; CPU_FOREACH ( cpuid ) { nwsp = DPCPU_ID_PTR ( cpuid , nws ) ; if ( nwsp -> nws_intr_event == NULL ) continue ; NWS_LOCK ( nwsp ) ; snwsp = & snws_array [ counter ] ; snwsp -> snws_version = sizeof ( * snwsp ) ; snwsp -> snws_wsid = cpuid ; snwsp -> snws_cpu = cpuid ; if ( nwsp -> nws_intr_event != NULL ) snwsp -> snws_flags |= NETISR_SNWS_FLAGS_INTR ; NWS_UNLOCK ( nwsp ) ; counter ++ ; } NETISR_RUNLOCK ( & tracker ) ; KASSERT ( counter <= MAXCPU , ( " " , counter ) ) ; error = SYSCTL_OUT ( req , snws_array , sizeof ( * snws_array ) * counter ) ; free ( snws_array , M_TEMP ) ; return ( error ) ; }
Sysctl monitoring for netisr: query a list of workstreams.
Sysctl monitoring for netisr : query a list of workstreams .
/*
		 * For now, we equate workstream IDs and CPU IDs in the
		 * kernel, but expose them independently to userspace in case
		 * that assumption changes in the future.
		 */