Received: by 10.223.176.46 with SMTP id f43csp956067wra; Fri, 19 Jan 2018 04:51:17 -0800 (PST) X-Google-Smtp-Source: ACJfBovOgXOoW8IWwp/CNN8bpMVJ50+tDprOHqtzd14XF/wlqf887MU6Ry2+h3hlLOjH0vR50WSG X-Received: by 2002:a17:902:b08a:: with SMTP id p10-v6mr1525882plr.133.1516366277285; Fri, 19 Jan 2018 04:51:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516366277; cv=none; d=google.com; s=arc-20160816; b=Vak3XXMTROFRvJkX80gmT1lfzmKoM8232ycjtUJ0oaukuXMJypBjT5gbFkvtledbny FFOFgHP0ZwvyoblXR6F3OOAzI51fNYMU2Ju1BJtTXHXfl3MeEs3WfRGfO61lPDyjdQen 8qot/VvZSQu1zq5WmYCLJEeT7zT4ho3YAB0/s3UloCKIibMmbuFC/C/EbJTDHqjY3XJe qPVArPDBcMvvk5cBsDiOHP0+zdpXR40O7HelMcT5MkbKc8Dekp5+5jGzmk3dXVmT6Y64 JoPrnmtiQkbMzlt9JqyvKlRI6gyL2XSOUrlM9vXZggF7tjjTWHTXSPoe4l9k2jHYP2SL IX6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=/t9WQyd9+gtkwXToQ5QXyJ7XkkV5iKUj1We+7A3xUx8=; b=C9ClucGZNr1tLAdDn+KWSN4+C1DuiAufTiobmkHl4FN5b8cMrD8rar9OkD5hj1XR4Z sVmB+k+ry5fcmQB0e8nw9uFDAmynS+pcCtoGXF9ygji5e0T+kbhvRr6SN91lpU2DeYWQ USyXHyjT1eQe0W7SLHvAwxBHsivaU/W9EwmPXer7LdnVPMe3dNdmvly4ELveVzRYSDHh GKUpdivOOLTahcqDZfayNmEwBcWPlkkeu1iYH3J/Jnjr/XwmJp+oTLgFQmaBdiTHH8oi +Ya9VQ2xDmO1QKS2x8shIJKSTxO7oF7cgYKueV2rsdKhN2HVAMtEMGmoATrqtS2aRkU5 QzRA== 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 u69si8152113pgb.10.2018.01.19.04.51.02; Fri, 19 Jan 2018 04:51:17 -0800 (PST) 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 S1755197AbeASMuH (ORCPT + 99 others); Fri, 19 Jan 2018 07:50:07 -0500 Received: from mx2.suse.de ([195.135.220.15]:57807 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751212AbeASMuB (ORCPT ); Fri, 19 Jan 2018 07:50:01 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0679CABD0; Fri, 19 Jan 2018 12:49:59 +0000 (UTC) Date: Fri, 19 Jan 2018 13:49:57 +0100 From: Michal Hocko To: Nitin Gupta Cc: steven.sistare@oracle.com, Nitin Gupta , Andrew Morton , Ingo Molnar , Mel Gorman , Nadav Amit , Minchan Kim , "Kirill A. Shutemov" , Peter Zijlstra , Vegard Nossum , "Levin, Alexander (Sasha Levin)" , Mike Rapoport , Hillf Danton , Shaohua Li , Anshuman Khandual , Andrea Arcangeli , David Rientjes , Rik van Riel , Jan Kara , Dave Jiang , =?iso-8859-1?B?Suly9G1l?= Glisse , Matthew Wilcox , Ross Zwisler , Hugh Dickins , Tobin C Harding , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm: Reduce memory bloat with THP Message-ID: <20180119124957.GA6584@dhcp22.suse.cz> References: <1516318444-30868-1-git-send-email-nitingupta910@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1516318444-30868-1-git-send-email-nitingupta910@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 18-01-18 15:33:16, Nitin Gupta wrote: > From: Nitin Gupta > > Currently, if the THP enabled policy is "always", or the mode > is "madvise" and a region is marked as MADV_HUGEPAGE, a hugepage > is allocated on a page fault if the pud or pmd is empty. This > yields the best VA translation performance, but increases memory > consumption if some small page ranges within the huge page are > never accessed. Yes, this is true but hardly unexpected for MADV_HUGEPAGE or THP always users. > An alternate behavior for such page faults is to install a > hugepage only when a region is actually found to be (almost) > fully mapped and active. This is a compromise between > translation performance and memory consumption. Currently there > is no way for an application to choose this compromise for the > page fault conditions above. Is that really true? We have /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none This is not reflected during the PF of course but you can control the behavior there as well. Either by the global setting or a per proces prctl. > With this change, whenever an application issues MADV_DONTNEED on a > memory region, the region is marked as "space-efficient". For such > regions, a hugepage is not immediately allocated on first write. Kirill didn't like it in the previous version and I do not like this either. You are adding a very subtle side effect which might completely unexpected. Consider userspace memory allocator which uses MADV_DONTNEED to free up unused memory. Now you have put it out of THP usage basically. If the memory is used really scarce then we have MADV_NOHUGEPAGE. -- Michal Hocko SUSE Labs