Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751122AbdCQIw6 (ORCPT ); Fri, 17 Mar 2017 04:52:58 -0400 Received: from mail-pg0-f42.google.com ([74.125.83.42]:36167 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750885AbdCQIw4 (ORCPT ); Fri, 17 Mar 2017 04:52:56 -0400 Date: Fri, 17 Mar 2017 01:52:53 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: "Huang, Ying" cc: Andrew Morton , Andi Kleen , Dave Hansen , Shaohua Li , Rik van Riel , Johannes Weiner , Michal Hocko , Tim Chen , Mel Gorman , "Kirill A. Shutemov" , =?UTF-8?Q?J=C3=A9r=C3=B4me_Glisse?= , Aaron Lu , Hugh Dickins , Minchan Kim , Ingo Molnar , Vegard Nossum , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 4/5] mm, swap: Try kzalloc before vzalloc In-Reply-To: <20170317064635.12792-4-ying.huang@intel.com> Message-ID: References: <20170317064635.12792-1-ying.huang@intel.com> <20170317064635.12792-4-ying.huang@intel.com> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 883 Lines: 18 On Fri, 17 Mar 2017, Huang, Ying wrote: > From: Huang Ying > > Now vzalloc() is used in swap code to allocate various data > structures, such as swap cache, swap slots cache, cluster info, etc. > Because the size may be too large on some system, so that normal > kzalloc() may fail. But using kzalloc() has some advantages, for > example, less memory fragmentation, less TLB pressure, etc. So change > the data structure allocation in swap code to try to use kzalloc() > firstly, and fallback to vzalloc() if kzalloc() failed. > I'm concerned about preferring kzalloc() with __GFP_RECLAIM since the page allocator will try to do memory compaction for high-order allocations when the vzalloc() would have succeeded immediately. Do we necessarily want to spend time doing memory compaction and direct reclaim for contiguous memory if it's not needed?