From patchwork Tue Nov 30 13:56:48 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changli Gao X-Patchwork-Id: 73603 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 4001E1007D6 for ; Wed, 1 Dec 2010 00:57:27 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752228Ab0K3N5W (ORCPT ); Tue, 30 Nov 2010 08:57:22 -0500 Received: from mail-gw0-f46.google.com ([74.125.83.46]:45502 "EHLO mail-gw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751931Ab0K3N5W (ORCPT ); Tue, 30 Nov 2010 08:57:22 -0500 Received: by gwj20 with SMTP id 20so2691741gwj.19 for ; Tue, 30 Nov 2010 05:57:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=e5zShrLGERl3e7OxeZ4d6mXNj8dBSHOuLc7AQOw4Gyc=; b=a9lrPe2oD5zaG/AWtKKn9QC/Tb1D6Lr5g2Sa98EErAbIxGgoc2OQ4rlLaBiEN8u+M4 PWtKksvmJw/nuejAUBm+r7YdvIYA0UtqFEtx3DbKAwypF40Ht2s2eg+2T4jiGxZfnqA2 pif4JdIzu9ZgJ0SK0teV8Jsk6WxiMDPzhm0UI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=IfyGOJAmlJ9uRsSrui1PMMHxMsntYa0asSoHg83AR6gpvSESyXeg5WPXhc8+FFTgqs wDogGXzUKL4RDadXpYTW7jlIcxxj+jWDhscY8aKSrckZHUbwosexCTviJ0aYvGNY4NNc sMVwr+cIrloVFiCz3V03C4DRF/1dZveRoYNjA= Received: by 10.151.26.18 with SMTP id d18mr12956478ybj.11.1291125441287; Tue, 30 Nov 2010 05:57:21 -0800 (PST) Received: from localhost.localdomain ([221.239.34.230]) by mx.google.com with ESMTPS id p30sm4056938ybk.20.2010.11.30.05.57.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 30 Nov 2010 05:57:18 -0800 (PST) From: Changli Gao To: "David S. Miller" Cc: Eric Dumazet , Jiri Pirko , Neil Horman , netdev@vger.kernel.org, Changli Gao Subject: [PATCH 1/2] af_packet: use vmalloc_to_page() instead for the addresss returned by vmalloc() Date: Tue, 30 Nov 2010 21:56:48 +0800 Message-Id: <1291125408-14389-1-git-send-email-xiaosuo@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The following commit causes the pgv->buffer may point to the memory returned by vmalloc(). And we can't use virt_to_page() for the vmalloc address. This patch introduces a new inline function pgv_to_page(), which calls vmalloc_to_page() for the vmalloc address, and virt_to_page() for the __get_free_pages address. commit 0e3125c755445664f00ad036e4fc2cd32fd52877 Author: Neil Horman Date: Tue Nov 16 10:26:47 2010 -0800 packet: Enhance AF_PACKET implementation to not require high order contiguous memory allocation (v4) Signed-off-by: Changli Gao --- net/packet/af_packet.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 422705d..0171b20 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -224,6 +224,13 @@ struct packet_skb_cb { #define PACKET_SKB_CB(__skb) ((struct packet_skb_cb *)((__skb)->cb)) +static inline struct page *pgv_to_page(void *addr) +{ + if (is_vmalloc_addr(addr)) + return vmalloc_to_page(addr); + return virt_to_page(addr); +} + static void __packet_set_status(struct packet_sock *po, void *frame, int status) { union { @@ -236,11 +243,11 @@ static void __packet_set_status(struct packet_sock *po, void *frame, int status) switch (po->tp_version) { case TPACKET_V1: h.h1->tp_status = status; - flush_dcache_page(virt_to_page(&h.h1->tp_status)); + flush_dcache_page(pgv_to_page(&h.h1->tp_status)); break; case TPACKET_V2: h.h2->tp_status = status; - flush_dcache_page(virt_to_page(&h.h2->tp_status)); + flush_dcache_page(pgv_to_page(&h.h2->tp_status)); break; default: pr_err("TPACKET version not supported\n"); @@ -263,10 +270,10 @@ static int __packet_get_status(struct packet_sock *po, void *frame) h.raw = frame; switch (po->tp_version) { case TPACKET_V1: - flush_dcache_page(virt_to_page(&h.h1->tp_status)); + flush_dcache_page(pgv_to_page(&h.h1->tp_status)); return h.h1->tp_status; case TPACKET_V2: - flush_dcache_page(virt_to_page(&h.h2->tp_status)); + flush_dcache_page(pgv_to_page(&h.h2->tp_status)); return h.h2->tp_status; default: pr_err("TPACKET version not supported\n"); @@ -803,8 +810,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct page *p_start, *p_end; u8 *h_end = h.raw + macoff + snaplen - 1; - p_start = virt_to_page(h.raw); - p_end = virt_to_page(h_end); + p_start = pgv_to_page(h.raw); + p_end = pgv_to_page(h_end); while (p_start <= p_end) { flush_dcache_page(p_start); p_start++; @@ -915,7 +922,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb, } err = -EFAULT; - page = virt_to_page(data); + page = pgv_to_page(data); offset = offset_in_page(data); len_max = PAGE_SIZE - offset; len = ((to_write > len_max) ? len_max : to_write);