From patchwork Tue Nov 29 18:23:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 700676 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 3tSsQS5kW8z9vDr for ; Wed, 30 Nov 2016 05:24:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="mMKrUR2Q"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934023AbcK2SX3 (ORCPT ); Tue, 29 Nov 2016 13:23:29 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:36295 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933960AbcK2SXS (ORCPT ); Tue, 29 Nov 2016 13:23:18 -0500 Received: by mail-pf0-f193.google.com with SMTP id c4so8749517pfb.3; Tue, 29 Nov 2016 10:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=ugk3hDq9wDQq1bvO3t+WDDhyi+FBmKAzJyeFPRVSyPY=; b=mMKrUR2Q8brG0fpEO73HfAR2WKhFWE1g0Erc1sPHd3DYkqGLWPSJEErTL9m06V4Ycu n74IjJ+qKbneWmfDwaTUsieKM0TGS09qtPj2A4Az41BA5Lfowy20fAUtx47Gxvc86Mjs WntHAaGqzbPH7yLwB5GzbR2IAy5S6yqUBHRhMAa7fyEr5VWu1lieI0ifAfoFtW7JIded Pkkv5TPFW/sZt0Qld7884Pit4Q8N09/2E6cZfIOu0FmQH6Cx9w4nuQJgPi7eBkDLxScQ lh81eR3SCs0aSFhsw6pHE4oQjjFmd4sjwvgJAdiYmjN1YsTT6c1ZEf4At9XsNBaINGss y96g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=ugk3hDq9wDQq1bvO3t+WDDhyi+FBmKAzJyeFPRVSyPY=; b=NKLWpYWqLDV/epvk4GQURi9j8ZnJmuo/xsVgQSu2iE+9OiojEMcP3jRZ+bfB2EWZGd 212WjXG/NubmQezZZoZsmAYNnClwb9ITfsVXjImwAcH5w/Iawe9FvYn6ugMqyydLBYa+ xCoWajz7P/s6E5gKSYR2+VVt4vFp6tm0JjjKEpLIITbkmSPTAIrH1zBz5eMDUZpAc7D8 VNpiFxrIDWgkRBNbt6DmcdmeUNJF29Fnm0tWI59iV29gY5+JuQsXN2YvTGMMjqhrv8fL GY1MZPrQrUHlJuZgdfXs+GLpI3gvIItySX6WtzR4stTcMM2tWMhnWXBNRQcR85pm6Y0P ATFA== X-Gm-Message-State: AKaTC01Vz31khwM2bXhOtiY735bzNI6ztIejPoIHunUegLhwTioayvFKZIh8UgtBsdhTwQ== X-Received: by 10.84.143.162 with SMTP id 31mr64246657plz.2.1480443797147; Tue, 29 Nov 2016 10:23:17 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id y134sm96742285pfg.81.2016.11.29.10.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 10:23:15 -0800 (PST) Subject: [mm PATCH 1/3] mm: Rename __alloc_page_frag to page_frag_alloc and __free_page_frag to page_frag_free From: Alexander Duyck To: linux-mm@kvack.org, akpm@linux-foundation.org Cc: netdev@vger.kernel.org, edumazet@google.com, davem@davemloft.net, jeffrey.t.kirsher@intel.com, linux-kernel@vger.kernel.org Date: Tue, 29 Nov 2016 10:23:15 -0800 Message-ID: <20161129182315.13445.17597.stgit@localhost.localdomain> In-Reply-To: <20161129182010.13445.31256.stgit@localhost.localdomain> References: <20161129182010.13445.31256.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Alexander Duyck This patch renames the page frag functions to be more consistent with other APIs. Specifically we place the name page_frag first in the name and then have either an alloc or free call name that we append as the suffix. This makes it a bit clearer in terms of naming. In addition we drop the leading double underscores since we are technically no longer a backing interface and instead the front end that is called from the networking APIs. The last bit I changed is I rebased page_frag_free to actually function very similar to the function free_pages, the only real difference now is the fact that we have to get the page order by calling compound page instead of having it passed as a part of the function call. Signed-off-by: Alexander Duyck --- include/linux/gfp.h | 6 +++--- include/linux/skbuff.h | 2 +- mm/page_alloc.c | 20 ++++++++++++-------- net/core/skbuff.c | 8 ++++---- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index 4175dca4ac39..6238c74e0a01 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -508,9 +508,9 @@ extern struct page *alloc_pages_vma(gfp_t gfp_mask, int order, struct page_frag_cache; extern void __page_frag_drain(struct page *page, unsigned int order, unsigned int count); -extern void *__alloc_page_frag(struct page_frag_cache *nc, - unsigned int fragsz, gfp_t gfp_mask); -extern void __free_page_frag(void *addr); +extern void *page_frag_alloc(struct page_frag_cache *nc, + unsigned int fragsz, gfp_t gfp_mask); +extern void page_frag_free(void *addr); #define __free_page(page) __free_pages((page), 0) #define free_page(addr) free_pages((addr), 0) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 9c535fbccf2c..95799826a1e7 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2471,7 +2471,7 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, static inline void skb_free_frag(void *addr) { - __free_page_frag(addr); + page_frag_free(addr); } void *napi_alloc_frag(unsigned int fragsz); diff --git a/mm/page_alloc.c b/mm/page_alloc.c index bb668eab5ee4..4218795a4694 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3931,8 +3931,8 @@ void __page_frag_drain(struct page *page, unsigned int order, } EXPORT_SYMBOL(__page_frag_drain); -void *__alloc_page_frag(struct page_frag_cache *nc, - unsigned int fragsz, gfp_t gfp_mask) +void *page_frag_alloc(struct page_frag_cache *nc, + unsigned int fragsz, gfp_t gfp_mask) { unsigned int size = PAGE_SIZE; struct page *page; @@ -3983,19 +3983,23 @@ void *__alloc_page_frag(struct page_frag_cache *nc, return nc->va + offset; } -EXPORT_SYMBOL(__alloc_page_frag); +EXPORT_SYMBOL(page_frag_alloc); /* * Frees a page fragment allocated out of either a compound or order 0 page. */ -void __free_page_frag(void *addr) +void page_frag_free(void *addr) { - struct page *page = virt_to_head_page(addr); + struct page *page; + + if (addr != 0) { + VM_BUG_ON(!virt_addr_valid(addr)); + page = virt_to_head_page(addr); - if (unlikely(put_page_testzero(page))) - __free_pages_ok(page, compound_order(page)); + __free_pages(page, compound_order(page)); + } } -EXPORT_SYMBOL(__free_page_frag); +EXPORT_SYMBOL(page_frag_free); static void *make_alloc_exact(unsigned long addr, unsigned int order, size_t size) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 4c96cb18c214..6cf779a9ad4c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -369,7 +369,7 @@ static void *__netdev_alloc_frag(unsigned int fragsz, gfp_t gfp_mask) local_irq_save(flags); nc = this_cpu_ptr(&netdev_alloc_cache); - data = __alloc_page_frag(nc, fragsz, gfp_mask); + data = page_frag_alloc(nc, fragsz, gfp_mask); local_irq_restore(flags); return data; } @@ -391,7 +391,7 @@ static void *__napi_alloc_frag(unsigned int fragsz, gfp_t gfp_mask) { struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache); - return __alloc_page_frag(&nc->page, fragsz, gfp_mask); + return page_frag_alloc(&nc->page, fragsz, gfp_mask); } void *napi_alloc_frag(unsigned int fragsz) @@ -441,7 +441,7 @@ struct sk_buff *__netdev_alloc_skb(struct net_device *dev, unsigned int len, local_irq_save(flags); nc = this_cpu_ptr(&netdev_alloc_cache); - data = __alloc_page_frag(nc, len, gfp_mask); + data = page_frag_alloc(nc, len, gfp_mask); pfmemalloc = nc->pfmemalloc; local_irq_restore(flags); @@ -505,7 +505,7 @@ struct sk_buff *__napi_alloc_skb(struct napi_struct *napi, unsigned int len, if (sk_memalloc_socks()) gfp_mask |= __GFP_MEMALLOC; - data = __alloc_page_frag(&nc->page, len, gfp_mask); + data = page_frag_alloc(&nc->page, len, gfp_mask); if (unlikely(!data)) return NULL;