Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2462640imm; Thu, 16 Aug 2018 09:58:09 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxrJ+ZEl9/XLbRpwXCKpwgcZryGhfG1jy44L29AnCHYovVGcmxwzoAeSfR1zS6qtRuPsqJF X-Received: by 2002:a17:902:9f90:: with SMTP id g16-v6mr29699367plq.304.1534438689664; Thu, 16 Aug 2018 09:58:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534438689; cv=none; d=google.com; s=arc-20160816; b=b+N8NXTDGxzjAy6lFaA3H+RcBNl8b0p3/JN50BiiXF8IlHmXJi6S2RUtuVuyMJdyoo KCJI+qc7PzU7onfS0lP2xO8fS9l9/lmWt/cmsdrG2Lr3tvjjI8OecPuE7FoalNebW62P vDZ4WCTbtaIRZTzRAT9aGOmyVXnvrXctvqQVDLIy/wmvhk9tbL/YUfz0ZMC2ClQHVi+n uPaBkdjR9R+KflirY3xackW3alW8I7zExmd+TPx3Ez7OCucqTeWQ8SS5CGAAstd0lzPC x6iDswZgMVe/6vT9Ufv/F+QwK1hc96qCOxJMtWrGXqatSQtGPF/yYfwuTMhlydROrhyx K/lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=mDl6SLDFzmiC0bcMx8wCI6SD9r9FKkCx0WQrDvCfxdY=; b=JOZWiFGBgLBay6JUKlD1kozy3Rpog7UVj+9VdrLPGUcRSkrI8EG/GP5WxB+fg7sfrB O8z2OvgaegzZJSKys62Ktl7ePoe2jgUFH622TH6IZlfMNodvSIAMSgdApvq03GHDdupW rnoVyfdtx377PHMpIuvL5DLNMan6vOWcP2kk4WJJQfu1Um9bklLPdX9i70GNf8q2IXQQ RVYBTr6236/Bl2VDkwmrdazmr/QHPxjTvogkdjYpuMCnkPr4lZNALDH+JTMtpEo9z4oo yNY9eDW923J+lefzz+m3fAjfCACXSSMwAVAgg1oPmYNuwnUlqggkeqFv3/dSTVnP+SSz cnfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i2-v6si23518995pgo.121.2018.08.16.09.57.54; Thu, 16 Aug 2018 09:58:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390391AbeHPMPJ (ORCPT + 99 others); Thu, 16 Aug 2018 08:15:09 -0400 Received: from mx60.baidu.com ([61.135.168.60]:30992 "EHLO tc-sys-mailedm03.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390348AbeHPMPJ (ORCPT ); Thu, 16 Aug 2018 08:15:09 -0400 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm03.tc.baidu.com (Postfix) with ESMTP id E46BC624007; Thu, 16 Aug 2018 17:17:37 +0800 (CST) From: Li RongQing To: Andrew Morton , Dan Williams , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Michal Hocko , "Kirill A. Shutemov" , Matthew Wilcox , Souptick Joarder Subject: [PATCH] mm: introduce kvvirt_to_page() helper Date: Thu, 16 Aug 2018 17:17:37 +0800 Message-Id: <1534411057-26276-1-git-send-email-lirongqing@baidu.com> X-Mailer: git-send-email 1.7.10.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The new helper returns address mapping page, which has several users in individual subsystem, like mem_to_page in xfs_buf.c and pgv_to_page in af_packet.c, after this, they can be unified Signed-off-by: Zhang Yu Signed-off-by: Li RongQing --- include/linux/mm.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 68a5121694ef..bb34a3c71df5 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -599,6 +599,14 @@ static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) return kvmalloc_array(n, size, flags | __GFP_ZERO); } +static inline struct page *kvvirt_to_page(const void *addr) +{ + if (!is_vmalloc_addr(addr)) + return virt_to_page(addr); + else + return vmalloc_to_page(addr); +} + extern void kvfree(const void *addr); static inline atomic_t *compound_mapcount_ptr(struct page *page) -- 2.16.2