[cgl_discussion] Re: device enumeration

Perez-Gonzalez, Inaky inaky.perez-gonzalez at intel.com
Fri Feb 7 11:19:47 PST 2003

> >Then change /sbin/hotplug ... its main benefit is your are 
> NOT constrained
> >by a model. Make it pass, real fast, it's parameters to a 
> daemon that is
> >already running via the fastest method you can devise [eg: 
> shared memory].
> >  
> >
> There is no way to do this, since /sbin/hotplug is executed each time 
> and cannot be run as a daemon.


struct hpd_comm_area
	semaphore__t sem;
	char         ring[ENTRIES][MAX_CMDLINE_LENGTH];
	unsigned     write_entry, read_entry;

int main (int argc, char **argv)
	char **top = argv + argc;
	fd = open ("/dev/shm/hot-plug-daemon-communication-area", O_RDWR);
	buffer = (struct hpd_comm_area*) 
         mmap (NULL, BIG, SHARED, WRITEABLE...blahblah ... fd, ...);
	down (&buffer->sem);
	buffer->ring[buffer->read_entry][0] = 0;
	for (argv++; argv < top; argv++) {
		strcat (buffer->ring[buffer->read_entry], *argv);
		strcat (buffer->ring[buffer->read_entry], " ");
	buffer->read_entry %= ENTRIES;
	/* Verify it does not clash with write_entry */
	up (buffer->sem);
	msync (...);	
	munmap (buffer, BIG);
	return 0;

This should  be fast enough - the copying can be greatly optimized, as well
as the actual system of passing the data along.

> the 20ms is mostly for the OS to shut down its internal data 
> structures. 
>  /sbin/hotplug adds approx 25 msec to the entire operation.  1 second 
> may be ok for shutting down a typical windows server system, 
> but a cpu 
> or disk blade that can be removed (such as compact pci or 
> advanced tca) 
> needs faster performance.

Still, if you are going to extract something, is because the NOC operator
noticed it was failing, right? well, I bet he can disable it as soon as he
notices it or in time for the $10/hour worker to get there and just unplug

Anyway, anybody who pays $10 for a qualified or high-risk job deserves their
hardware to be fried in the worst way possible.

Inaky Perez-Gonzalez -- Not speaking for Intel - opinions are my own [or my

More information about the cgl_discussion mailing list