From patchwork Mon Aug 22 23:01:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 9294885 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 99A9F60757 for ; Tue, 23 Aug 2016 04:01:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 888032887D for ; Tue, 23 Aug 2016 04:01:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CBDA28A63; Tue, 23 Aug 2016 04:01:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E7F732887D for ; Tue, 23 Aug 2016 04:01:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bc2rK-00051O-1z; Tue, 23 Aug 2016 03:58:42 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bbyEB-0001mW-4n for xen-devel@lists.xenproject.org; Mon, 22 Aug 2016 23:01:59 +0000 Received: from [85.158.143.35] by server-6.bemta-6.messagelabs.com id 1C/8D-11175-6648BB75; Mon, 22 Aug 2016 23:01:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKIsWRWlGSWpSXmKPExsVyMfTAEd2Ult3 hBo/nK1h83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBmfvi9nLLjIXfH6wEbWBsYmri5GLg4hgemM Ep1bbjOBOCwCzawSU3c+ZwRxJATms0r8W3uApYuRE8iJkVjUfIoZwq6Q2P31ClhcSEBR4sqSZ WwQo44wSTRcm8MKkmATUJO4/Gk9I4gtAlT04OVNsDizQJLEhO17gdZxcAgLeEn8PZ0JEmYRUJ U4emUtO4jNK+AkcX3aXKi9chI3z3UyQ8QFJU7OfMICMUZH4l3fA2YIW15i+9s5zBMYBWchKZu FpGwWkrIFjMyrGNWLU4vKUot0zfSSijLTM0pyEzNzdA0NzPRyU4uLE9NTcxKTivWS83M3MQID lwEIdjDOO+F/iFGSg0lJlPev8+5wIb6k/JTKjMTijPii0pzU4kOMMhwcShK8FU1AOcGi1PTUi rTMHGAMwaQlOHiURHi3gaR5iwsSc4sz0yFSpxiNObb8vraWiWPb1HtrmYRY8vLzUqXEectASg VASjNK8+AGwWL7EqOslDAvI9BpQjwFqUW5mSWo8q8YxTkYlYR5t4NM4cnMK4Hb9wroFCagU67 /3w5ySkkiQkqqgZHv/YaDcxREdm9e+PH0jAzG15xHs+b88PnwZ6nZl/m1H3iyUw2cBCOCj2SY dFRofzV1nLDy8lfVK++a9mY33+dR9t6+zHluje++Gp33Sd/SnDZZ2AodOn/F2vIJ2wNZXvN/G ut0OT57c70XjxFoeSFgcTi9ROj42022+yYXHjw0ZYrrvgyfN1xKLMUZiYZazEXFiQCFc4ey6A IAAA== X-Env-Sender: weiyj.lk@gmail.com X-Msg-Ref: server-11.tower-21.messagelabs.com!1471906915!29588745!1 X-Originating-IP: [209.85.192.196] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25906 invoked from network); 22 Aug 2016 23:01:56 -0000 Received: from mail-pf0-f196.google.com (HELO mail-pf0-f196.google.com) (209.85.192.196) by server-11.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 22 Aug 2016 23:01:56 -0000 Received: by mail-pf0-f196.google.com with SMTP id i6so7091173pfe.0 for ; Mon, 22 Aug 2016 16:01:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iudruZxD+UmIpstf8k2fTJHpKClxM6FFVxP9Lwsx03U=; b=KsTvo0XxZlCUYuQl/VEdjxbG2VUOJpppPTOmd8K42kJoApkF1n1cKoiJLyciuqkV2E TeNtk1nidgVu+ffTs+mlH+plH87szC+e41g6fsijsEYKQZv/XaBu1USGJ3fDkf63PUbN keQUznNojDN2poJZwZAJCZICGGv4WN3FwM3xSCXRMxLYruaHduD6riTMjaSitlJ5WL0v 4zFtPjHinAU3bTPPS2W1dTopRLxoHIvXeHuFOrpEmolVGvcj0e4fEK/IKtiHoK4iOYyS +mSUTwOvHaApxN/YBdkDJSGk/RucT9g1EEppsmnzXQWLO4gxO5BNxlCLCbzqhnMUC7VE gpVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iudruZxD+UmIpstf8k2fTJHpKClxM6FFVxP9Lwsx03U=; b=Et2Fv2WZN9D7+17fJeXucVctaSjZ2hDjmcqhQ9TkKDsNHg6YRS4ARI5/wAnG0AkMNy ZkVP+vzqk7sEInpGkdUYt6VHYWPEgK6nGrM1zX+EVLMiQxeNxFtzdAGujFth9jl5Ko84 Kb2Ahak1+4el/8zQegeB0IdNOnxZHzyslFK/0SXugt5KsIqFnrMIykWGT6IJLMgwi36o Qqee2xSYe7v0FpiV/kQOpFNi7CRz2ydRzOnR2H3vF/dSgGHYblbg9N2a4sZeh0urwJ24 cqnYko+/JRpEvFzjZ+ckVgUAAYiBapDjyFf5J4LyymOxtp+Hffc7EpyFlgUkFbwZh3cU e9+Q== X-Gm-Message-State: AEkoouvmJik//Q8yUT9YlzRbTNYTtvx/uYxG1NIBJzrcoLLXr8aHRv/sbGneedJXlB5BCQ== X-Received: by 10.98.62.144 with SMTP id y16mr47866490pfj.9.1471906914786; Mon, 22 Aug 2016 16:01:54 -0700 (PDT) Received: from localhost.localdomain.localdomain (ec2-52-192-197-227.ap-northeast-1.compute.amazonaws.com. [52.192.197.227]) by smtp.gmail.com with ESMTPSA id m65sm210142pfg.79.2016.08.22.16.01.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Aug 2016 16:01:54 -0700 (PDT) From: Wei Yongjun To: Wei Liu Date: Mon, 22 Aug 2016 23:01:29 +0000 Message-Id: <1471906889-20132-1-git-send-email-weiyj.lk@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 23 Aug 2016 03:58:41 +0000 Cc: xen-devel@lists.xenproject.org, Wei Yongjun , netdev@vger.kernel.org Subject: [Xen-devel] [PATCH -next] xen-netback: using kfree_rcu() to simplify the code X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Wei Yongjun The callback function of call_rcu() just calls a kfree(), so we can use kfree_rcu() instead of call_rcu() + callback function. Signed-off-by: Wei Yongjun --- drivers/net/xen-netback/hash.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/xen-netback/hash.c b/drivers/net/xen-netback/hash.c index 282b16d..e8c5ddd 100644 --- a/drivers/net/xen-netback/hash.c +++ b/drivers/net/xen-netback/hash.c @@ -32,15 +32,6 @@ #include #include -static void xenvif_del_hash(struct rcu_head *rcu) -{ - struct xenvif_hash_cache_entry *entry; - - entry = container_of(rcu, struct xenvif_hash_cache_entry, rcu); - - kfree(entry); -} - static void xenvif_add_hash(struct xenvif *vif, const u8 *tag, unsigned int len, u32 val) { @@ -76,7 +67,7 @@ static void xenvif_add_hash(struct xenvif *vif, const u8 *tag, if (++vif->hash.cache.count > xenvif_hash_cache_size) { list_del_rcu(&oldest->link); vif->hash.cache.count--; - call_rcu(&oldest->rcu, xenvif_del_hash); + kfree_rcu(oldest, rcu); } } @@ -114,7 +105,7 @@ static void xenvif_flush_hash(struct xenvif *vif) list_for_each_entry_rcu(entry, &vif->hash.cache.list, link) { list_del_rcu(&entry->link); vif->hash.cache.count--; - call_rcu(&entry->rcu, xenvif_del_hash); + kfree_rcu(entry, rcu); } spin_unlock_irqrestore(&vif->hash.cache.lock, flags);