From owner-svn-src-all@FreeBSD.ORG Sat Jun 12 13:20:39 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 16AD4106564A; Sat, 12 Jun 2010 13:20:39 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 05DFB8FC21; Sat, 12 Jun 2010 13:20:39 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o5CDKc0K010173; Sat, 12 Jun 2010 13:20:38 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5CDKc4U010170; Sat, 12 Jun 2010 13:20:38 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201006121320.o5CDKc4U010170@svn.freebsd.org> From: Konstantin Belousov Date: Sat, 12 Jun 2010 13:20:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r209104 - in head/sys: kern sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jun 2010 13:20:39 -0000 Author: kib Date: Sat Jun 12 13:20:38 2010 New Revision: 209104 URL: http://svn.freebsd.org/changeset/base/209104 Log: Add modifications of devctl_notify(9) functions that take flags. Use flags to specify M_WAITOK/M_NOWAIT. M_WAITOK allows devctl to sleep for the memory allocation. As Warner noted, allowing the functions to sleep might cause reordering of the queued notifications. Reviewed by: imp, jh MFC after: 3 weeks Modified: head/sys/kern/subr_bus.c head/sys/sys/bus.h Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Sat Jun 12 13:10:03 2010 (r209103) +++ head/sys/kern/subr_bus.c Sat Jun 12 13:20:38 2010 (r209104) @@ -539,7 +539,7 @@ devctl_process_running(void) * that @p data is allocated using the M_BUS malloc type. */ void -devctl_queue_data(char *data) +devctl_queue_data_f(char *data, int flags) { struct dev_event_info *n1 = NULL, *n2 = NULL; struct proc *p; @@ -548,7 +548,7 @@ devctl_queue_data(char *data) goto out; if (devctl_queue_length == 0) goto out; - n1 = malloc(sizeof(*n1), M_BUS, M_NOWAIT); + n1 = malloc(sizeof(*n1), M_BUS, flags); if (n1 == NULL) goto out; n1->dei_data = data; @@ -588,12 +588,19 @@ out: return; } +void +devctl_queue_data(char *data) +{ + + devctl_queue_data_f(data, M_NOWAIT); +} + /** * @brief Send a 'notification' to userland, using standard ways */ void -devctl_notify(const char *system, const char *subsystem, const char *type, - const char *data) +devctl_notify_f(const char *system, const char *subsystem, const char *type, + const char *data, int flags) { int len = 0; char *msg; @@ -611,7 +618,7 @@ devctl_notify(const char *system, const if (data != NULL) len += strlen(data); len += 3; /* '!', '\n', and NUL */ - msg = malloc(len, M_BUS, M_NOWAIT); + msg = malloc(len, M_BUS, flags); if (msg == NULL) return; /* Drop it on the floor */ if (data != NULL) @@ -620,7 +627,15 @@ devctl_notify(const char *system, const else snprintf(msg, len, "!system=%s subsystem=%s type=%s\n", system, subsystem, type); - devctl_queue_data(msg); + devctl_queue_data_f(msg, flags); +} + +void +devctl_notify(const char *system, const char *subsystem, const char *type, + const char *data) +{ + + devctl_notify_f(system, subsystem, type, data, M_NOWAIT); } /* Modified: head/sys/sys/bus.h ============================================================================== --- head/sys/sys/bus.h Sat Jun 12 13:10:03 2010 (r209103) +++ head/sys/sys/bus.h Sat Jun 12 13:20:38 2010 (r209104) @@ -85,8 +85,11 @@ struct u_device { * included in case devctl_notify isn't sufficiently general. */ boolean_t devctl_process_running(void); +void devctl_notify_f(const char *__system, const char *__subsystem, + const char *__type, const char *__data, int __flags); void devctl_notify(const char *__system, const char *__subsystem, const char *__type, const char *__data); +void devctl_queue_data_f(char *__data, int __flags); void devctl_queue_data(char *__data); /**