From patchwork Wed Jul 7 17:13:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 58131 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D7121B6EE8 for ; Thu, 8 Jul 2010 03:13:43 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755018Ab0GGRNg (ORCPT ); Wed, 7 Jul 2010 13:13:36 -0400 Received: from mail-ey0-f174.google.com ([209.85.215.174]:63004 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754669Ab0GGRNe (ORCPT ); Wed, 7 Jul 2010 13:13:34 -0400 Received: by eya25 with SMTP id 25so236905eya.19 for ; Wed, 07 Jul 2010 10:13:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:references:mime-version:content-type:content-disposition :in-reply-to:user-agent; bh=YIsjrO2i78j9xVhFve77mNMFJDq48q4c/E+qxEpAVLQ=; b=m+vTk0aU2Y5MQxnYdqi7t3K1dTE5l8IOEj0htTe7ZmmxB3xtG6yr0gXeHVQvGZHa0p B6sXaE1MsrQM8nfmyrGkM9UEguV0qz4IZ49pen6Hxzh0zYF0nStzTNZFFyaFu9gPSy8n TJH+4EdzsQHutz/l1fWY6g1w3NUQsZ/kgt/XI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=hWZ2BkM9tDsajt9nWCjKFCw8RK3sEdtJ3nubnhe+3YKxSMjXudd7iZC1MzIINuuRBx IiFDU1umepQjlq4yEw8izTVOEcyLGavnvQG3ZHCDDSyN/300qMG0Onxq6fiI1Hx7Uivn pOsAkEjpEr96gGEmroatlx1WZdJ2rbz3nKR/s= Received: by 10.213.31.133 with SMTP id y5mr5813576ebc.68.1278522812269; Wed, 07 Jul 2010 10:13:32 -0700 (PDT) Received: from localhost (mail.dev.rtsoft.ru [213.79.90.226]) by mx.google.com with ESMTPS id x54sm62897276eeh.5.2010.07.07.10.13.30 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 Jul 2010 10:13:31 -0700 (PDT) Date: Wed, 7 Jul 2010 21:13:29 +0400 From: Anton Vorontsov To: kgdb-bugreport@lists.sourceforge.net Cc: Russell King , "David S. Miller" , Jason Wessel , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH RFC 3/4] net: Implement napi_try_disable() Message-ID: <20100707171329.GC20015@oksana.dev.rtsoft.ru> References: <20100707171222.GA16448@oksana.dev.rtsoft.ru> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100707171222.GA16448@oksana.dev.rtsoft.ru> User-Agent: Mutt/1.5.20 (2009-06-14) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org For KGDBoE we'll need to disable NAPI, so that we don't randomly interrupt secondary CPUs while they process networking stuff. We need to wait for NAPI to become disabled from an atomic context, thus we can't use napi_disable() as it calls msleep(). Plus, in KGDB we have to always poll for IPIs during busy-waiting, which means that we must implement the function in a such way that we can do some caller specific work during the time we wait for NAPI disable, so just changing msleep() to mdelay() won't work. Signed-off-by: Anton Vorontsov --- include/linux/netdevice.h | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 08a1dd8..4fc24eb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -414,6 +414,27 @@ extern void __napi_complete(struct napi_struct *n); extern void napi_complete(struct napi_struct *n); /** + * napi_try_disable - try to prevent NAPI from scheduling + * @n: napi context + * + * This call is similar to napi_disable(), except that it doesn't + * wait till any outstanding processing completes, but returns + * whether napi was successfuly disabled. + * + * Note that you still must wait till napi is actually disabled, + * so the only benefit from using this call is that you can do + * some useful work while you wait. + */ +static inline int napi_try_disable(struct napi_struct *n) +{ + set_bit(NAPI_STATE_DISABLE, &n->state); + if (test_and_set_bit(NAPI_STATE_SCHED, &n->state)) + return 0; + clear_bit(NAPI_STATE_DISABLE, &n->state); + return 1; +} + +/** * napi_disable - prevent NAPI from scheduling * @n: napi context *