Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp669652imu; Fri, 9 Nov 2018 04:15:43 -0800 (PST) X-Google-Smtp-Source: AJdET5ebLEweBDrWD+JvjmDJmzJDoHAW4hbLsxGgxrrCVkk1ochgsr9YgPymHJCJBV3McvEK4w9n X-Received: by 2002:a63:9c1a:: with SMTP id f26mr7282322pge.381.1541765743461; Fri, 09 Nov 2018 04:15:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541765743; cv=none; d=google.com; s=arc-20160816; b=sYFxKNmAVud2g5jyOiD2Uyzc0LUOH4thIng2QGzuAHcV3qLpky2v6PLsImAA8grAwU 8hyyTjHd9IcNKHcW7iGWc1t53Dr66Eye5aftIFZPRIMvenaGEXX9qot4gaRI22oE9y6+ VsfmSj5WmCQn2ZfIR0gajH/ErtCxfL6xJp7/aRPlm+LmlVYgXKk3BVS+rROv5Aq4TSiC jxyQ0nO0UI7ochNlUO2uV+dmX6b0y5AHJDQ/k9oD7VC9+JLI/beEvki8D84CxVs2z60u 9sBlupf/rH7ATxux3jZbao7VAVAXL/41OLXpIToW4CFbtJNUkx1Z6jq4ks/z/iPSLMie xgmw== 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:dkim-signature; bh=kUsYFeo1kLBI3BPnBoUz9u43BAsr3XJ229Wlh0/P+5g=; b=S3U99ZBQAaeodCKq8YP7j0i5IOhiCZk7w/CZ017mUQ43a75KI6+0uuBnTGW9TJ/t2U OQ935p9BQGkQLxM2cCYiOUQEmIHu7jyVdb6kOj0aWj4j1XxYJiTsDVhhEYEORg+eQF/q Pi1kbQeNh1OA4Ov8BEUh5evHo6OlPmuT08l2cqZDkglFXE5Tkm16LqiTj3Be83MoQL3z db5Shs16QWwW8xYz/CzNlQaPIoOludGXQBFd7S+EHr631kzp6aMZ3pRRAJ10pEpT0+QA qWFaQAcEELdOkyHHN8R0Bc9Kyd0DnjogynqsYY0LpVDrRnVM/HK18456CAp611BpCxG7 5PnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="ecMs/vgd"; 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 n23-v6si6833815pgb.330.2018.11.09.04.15.18; Fri, 09 Nov 2018 04:15:43 -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; dkim=pass header.i=@shutemov-name.20150623.gappssmtp.com header.s=20150623 header.b="ecMs/vgd"; 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 S1728046AbeKIVxp (ORCPT + 99 others); Fri, 9 Nov 2018 16:53:45 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:36073 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727560AbeKIVxp (ORCPT ); Fri, 9 Nov 2018 16:53:45 -0500 Received: by mail-lf1-f68.google.com with SMTP id h192so1174181lfg.3 for ; Fri, 09 Nov 2018 04:13:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kUsYFeo1kLBI3BPnBoUz9u43BAsr3XJ229Wlh0/P+5g=; b=ecMs/vgdR13EYHuZiFRbTrcMtf0k4CLpYY5+RpjavdlmDQe3rGtZKvs/ngWvPEfX8f ghfM3XTtjDK3a+bC2RgBT6BjLT7RMeGpCjXokcw+IEOW5oYKEVlREf+l2TairfnZ6JRh mlrI3H5Fk0UvYixfIiW0KlcqgiBV8Rg/nWfGZUUca30gWVdu8jApyOnJoEjQa1cK0uCK Nr04/EQSLSMkLtOvfcyvJEIKqhP2117EdM5U0/Lr76UA0ru/sWtLb0PUaDDKDCzNcQqO vK1ZeshFLtG6rnwTlHWQg0iXT5iG5CjJYbrL7MHDfxF1pDDpLOhgPzPihF7gDykM+5sv dXnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kUsYFeo1kLBI3BPnBoUz9u43BAsr3XJ229Wlh0/P+5g=; b=pv4V9HjXWIv0tyi6IkR/txfu3y1gwpw8/EXAsOlKKRGnC2+82jRth1lHOJqDL4aMDP QJw+p2z2Vzo7UXf6dRKoRxgzE7eWzeBXdafeWk+EkjB58kd+ORlrYSKRcMnzIed59A+T pnvjdZXraoeLlIhUVDZGAMk6ZFgF7I3ubkfCToTEDYhW40VMdLfxt5C6dD/eFYwWj3wW 9VAjXgWxJYNy6mt0+e/lAak4+e1WIaD6HCDOVabdPJnX/9ghaWyiT6jC2sv05AAtkTlx tWuqj0OWBt0HftZh6ReU1SbYEp2D0shUGhqXRBdm0HSyRiXqklmBYf4/NA9t9q5eIrLx 8pGg== X-Gm-Message-State: AGRZ1gLJvAtVXgGcybjyf4QW553Nc4/QTflLBOJNZ6uNU+k9uUatRYXS kl21KxujdbcFtmBdzwrwx5Qm3g== X-Received: by 2002:a19:4345:: with SMTP id m5mr5193889lfj.142.1541765602016; Fri, 09 Nov 2018 04:13:22 -0800 (PST) Received: from kshutemo-mobl1.localdomain (mm-34-243-122-178.mgts.dynamic.pppoe.byfly.by. [178.122.243.34]) by smtp.gmail.com with ESMTPSA id 10sm1251097lff.62.2018.11.09.04.13.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Nov 2018 04:13:21 -0800 (PST) Received: by kshutemo-mobl1.localdomain (Postfix, from userid 1000) id E24653002A1; Fri, 9 Nov 2018 15:13:18 +0300 (+03) Date: Fri, 9 Nov 2018 15:13:18 +0300 From: "Kirill A. Shutemov" To: Anthony Yznaga Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, aarcange@redhat.com, aneesh.kumar@linux.ibm.com, akpm@linux-foundation.org, jglisse@redhat.com, khandual@linux.vnet.ibm.com, kirill.shutemov@linux.intel.com, mgorman@techsingularity.net, mhocko@kernel.org, minchan@kernel.org, peterz@infradead.org, rientjes@google.com, vbabka@suse.cz, willy@infradead.org, ying.huang@intel.com, nitingupta910@gmail.com Subject: Re: [RFC PATCH] mm: thp: implement THP reservations for anonymous memory Message-ID: <20181109121318.3f3ou56ceegrqhcp@kshutemo-mobl1> References: <1541746138-6706-1-git-send-email-anthony.yznaga@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1541746138-6706-1-git-send-email-anthony.yznaga@oracle.com> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 08, 2018 at 10:48:58PM -0800, Anthony Yznaga wrote: > The basic idea as outlined by Mel Gorman in [2] is: > > 1) On first fault in a sufficiently sized range, allocate a huge page > sized and aligned block of base pages. Map the base page > corresponding to the fault address and hold the rest of the pages in > reserve. > 2) On subsequent faults in the range, map the pages from the reservation. > 3) When enough pages have been mapped, promote the mapped pages and > remaining pages in the reservation to a huge page. > 4) When there is memory pressure, release the unused pages from their > reservations. I haven't yet read the patch in details, but I'm skeptical about the approach in general for few reasons: - PTE page table retracting to replace it with huge PMD entry requires down_write(mmap_sem). It makes the approach not practical for many multi-threaded workloads. I don't see a way to avoid exclusive lock here. I will be glad to be proved otherwise. - The promotion will also require TLB flush which might be prohibitively slow on big machines. - Short living processes will fail to benefit from THP with the policy, even with plenty of free memory in the system: no time to promote to THP or, with synchronous promotion, cost will overweight the benefit. The goal to reduce memory overhead of THP is admirable, but we need to be careful not to kill THP benefit itself. The approach will reduce number of THP mapped in the system and/or shift their allocation to later stage of process lifetime. The only way I see it can be useful is if it will be possible to apply the policy on per-VMA basis. It will be very useful for malloc() implementations, for instance. But as a global policy it's no-go to me. Prove me wrong with performance data. :) -- Kirill A. Shutemov