From mboxrd@z Thu Jan 1 00:00:00 1970 From: Prarit Bhargava Date: Wed, 30 Mar 2005 16:31:57 +0000 Subject: Re: Virtual Console Hotplug Leads to OOM Message-Id: <424AD47D.9070209@sgi.com> MIME-Version: 1 Content-Type: multipart/mixed; boundary="------------070400060200090104060302" List-Id: References: <424AD41F.1040309@sgi.com> In-Reply-To: <424AD41F.1040309@sgi.com> To: linux-hotplug@vger.kernel.org This is a multi-part message in MIME format. --------------070400060200090104060302 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit It helps to attach the test code :) P. Prarit Bhargava wrote: > Colleagues, > > I've identified the following critical issue where the hotplug > subsystem can cause OOM-killer to run. IMO this is a critical issue > within hotplug -- in the case below, only the virtual console > subsystem is responsible. > > The virtual consoles that are being spawned are responsible for 2 > hotplug events for every console opened -- one on the opening of the > console, and one on the closing of the console. > > If you run the tty2_test which opens and closes ttys (attached to this > email) you'll see THOUSANDS of hotplug events. After running for 1 > minute on a 16p ia64 I had well over 4000 hotplug events. > > If we're unlucky enough to fall below the low-water memory point at > the same time tty2_test is spawning, the OOM-killer starts up. Memory > is taken up by the hotplug events ... and we're off into the weeds. > > The issue with the virtual console code is that it uses the > class_simple library. This is a problem as the library pre-defines a > global kset parent as class_obj (or at least AFAICT). This parent is > used by ALL subsystems using the class_simple, not just the virtual > console subsystem. > > This parent has a pointer to allow hotplug slot operations for all > it's children (including the virtual consoles). IMO zero-ing this > pointer out is not a valid option as this would break hotplug op's for > many other subystems. > > ** I did notice that the class struct has it's own hotplug value -- > can/should this be used to override the parent's hotplug operations? ** > > P. > > > --------------070400060200090104060302 Content-Type: text/plain; name="tty2_test.c" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="tty2_test.c" #include #include #include #include #include #include #include #include #define NTHREADS 300 void *thread_function(); int open_fail_num; int open_success; int main(int argc, char *argv[]) { int i, j; pthread_t thread_id[NTHREADS]; for(;;) { for(i=0; i < NTHREADS; i++) { pthread_create(&thread_id[i], NULL, &thread_function, NULL); } for(j=0; j < NTHREADS; j++) { pthread_join(thread_id[j], NULL); } printf("open failures: %i\n", open_fail_num); printf("open success: %i\n", open_success); } } void *thread_function() { int fd; time_t t; // fd = open("/dev/cua0", O_NONBLOCK); // fd = open("/dev/cua0", O_RDWR); fd = open("/dev/tty9", O_RDWR); // if (fd == -1) if (fd < 0) { open_fail_num++; // perror("open"); // exit(1); } else { open_success++; } /* just waste some random time */ t = (time((time_t *)0) &31L) << 6; while (t-- > 0) (void)time((time_t *)0); close(fd); // _exit(0); } --------------070400060200090104060302 Content-Type: text/plain; name="Makefile" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="Makefile" # # make test command # NAME_SRC=tty2_test CFLAGS= -O -g -Wall -I /usr/include/ LDFLAGS=-lpthread CC=cc GET=co SRCS=$(NAME_SRC).c OBJS=$(NAME_SRC).o DEPEND= makedepend $(CFLAGS) all: $(NAME_SRC) # To make an executable $(NAME_SRC): $(OBJS) $(CC) $(LDFLAGS) -o $@ $(OBJS) # what are the source dependencies depend: $(SRCS) $(DEPEND) $(SRCS) # clean out the junk clean: -rm $(NAME_SRC) *~ *.o # DO NOT DELETE THIS LINE -- make depend depends on it. $(NAME_SRC).o: /usr/include/sys/types.h /usr/include/sys/stat.h \ /usr/include/fcntl.h /usr/include/pthread.h --------------070400060200090104060302-- ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel