From owner-freebsd-net@FreeBSD.ORG Tue May 20 10:09:25 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D2957488 for ; Tue, 20 May 2014 10:09:25 +0000 (UTC) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [84.52.89.53]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 81BC423A9 for ; Tue, 20 May 2014 10:09:25 +0000 (UTC) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 734997F4D9; Tue, 20 May 2014 14:00:31 +0400 (MSK) X-DKIM: Sendmail DKIM Filter v2.8.2 shelob.oktetlabs.ru 734997F4D9 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1400580031; bh=tRb4ANkNETRGOTXLsji1ZMVGDWmSTmZT9aUZooOswUw=; l=1523; h=Message-ID:Date:From:MIME-Version:To:CC:Subject:Content-Type; b=VgOt8Ds0qsxtMNVEBIpzfxnT4rXLXWOWPdZcHx+8e+xPcqHGfLttux62DViLQsk9P Tsp68nw79mbRkAyUwSb3YoTflA5xwCUZrdVdWOnfS3tkyUsEGUfWepTnpOVcjX4nZB EEL5QowOv9LP+bOcfenF43VuHdthOHWYb9Zpz+8M= Message-ID: <537B27BF.7000800@oktetlabs.ru> Date: Tue, 20 May 2014 14:00:31 +0400 From: Andrew Rybchenko Organization: OKTET Labs User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: freebsd-net@freebsd.org Subject: sfxge: Do no allow EFSYS_MEM_ALLOC sleep Content-Type: multipart/mixed; boundary="------------030702020709090005030108" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 May 2014 10:09:25 -0000 This is a multi-part message in MIME format. --------------030702020709090005030108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit It solves locking problem when EFSYS_MEM_ALLOC is called in the context holding a mutex (not allowed to sleep). E.g. on interface bring up or multicast addresses addition. --------------030702020709090005030108 Content-Type: text/x-patch; name="alloc_nowait.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="alloc_nowait.patch" sfxge: Do no allow EFSYS_MEM_ALLOC sleep It solves locking problem when EFSYS_MEM_ALLOC is called in the context holding a mutex (not allowed to sleep). E.g. on interface bring up or multicast addresses addition. Submitted by: Andrew Rybchenko Sponsored by: Solarflare Communications, Inc. diff --git a/head/sys/dev/sfxge/common/efsys.h b/head/sys/dev/sfxge/common/efsys.h --- a/head/sys/dev/sfxge/common/efsys.h +++ b/head/sys/dev/sfxge/common/efsys.h @@ -701,7 +701,11 @@ #define EFSYS_KMEM_ALLOC(_esip, _size, _p) \ do { \ (_esip) = (_esip); \ - (_p) = malloc((_size), M_SFXGE, M_WAITOK|M_ZERO); \ + /* \ + * The macro is used in non-sleepable contexts, for \ + * example, holding a mutex. \ + */ \ + (_p) = malloc((_size), M_SFXGE, M_NOWAIT|M_ZERO); \ _NOTE(CONSTANTCONDITION) \ } while (B_FALSE) --------------030702020709090005030108--