From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8E98C433DB for ; Wed, 17 Feb 2021 08:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6920A64DFF for ; Wed, 17 Feb 2021 08:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231562AbhBQIWW (ORCPT ); Wed, 17 Feb 2021 03:22:22 -0500 Received: from mx2.suse.de ([195.135.220.15]:44654 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231616AbhBQIWV (ORCPT ); Wed, 17 Feb 2021 03:22:21 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1613550094; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+AtVtNBB4nXDoZsK/9xd9pLXgJM8teFm4x1vJhLij10=; b=Y9Ln5+k1Q/qEgc6nUUNieToU3pSXz895sM6C41AVkL2IpyIhrw17TYfKQhwtwe88DXVfp0 8tgvNzgb4hdKaodkjJ3RE+dwMAKzsGtoYXObPBvqJq17B9pqu5tnZ1mXpLBoE7OTVVHpjg 3IxoF5uDcnqBWKHiZS2BTcwfVNkSQyM= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4AD89B923; Wed, 17 Feb 2021 08:21:34 +0000 (UTC) Date: Wed, 17 Feb 2021 09:21:32 +0100 From: Michal Hocko To: David Rientjes Cc: Alex Shi , Hugh Dickins , Andrea Arcangeli , "Kirill A. Shutemov" , Song Liu , Matthew Wilcox , Minchan Kim , Vlastimil Babka , Chris Kennelly , linux-mm@kvack.org, linux-api@vger.kernel.org Subject: Re: [RFC] Hugepage collapse in process context Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-api@vger.kernel.org [Cc linux-api] On Tue 16-02-21 20:24:16, David Rientjes wrote: > Hi everybody, > > Khugepaged is slow by default, it scans at most 4096 pages every 10s. > That's normally fine as a system-wide setting, but some applications would > benefit from a more aggressive approach (as long as they are willing to > pay for it). > > Instead of adding priorities for eligible ranges of memory to khugepaged, > temporarily speeding khugepaged up for the whole system, or sharding its > work for memory belonging to a certain process, one approach would be to > allow userspace to induce hugepage collapse. > > The benefit to this approach would be that this is done in process context > so its cpu is charged to the process that is inducing the collapse. > Khugepaged is not involved. Yes, this makes a lot of sense to me. > Idea was to allow userspace to induce hugepage collapse through the new > process_madvise() call. This allows us to collapse hugepages on behalf of > current or another process for a vectored set of ranges. Yes, madvise sounds like a good fit for the purpose. > This could be done through a new process_madvise() mode *or* it could be a > flag to MADV_HUGEPAGE since process_madvise() allows for a flag parameter > to be passed. For example, MADV_F_SYNC. Would this MADV_F_SYNC be applicable to other madvise modes? Most existing madvise modes do not seem to make much sense. We can argue that MADV_PAGEOUT would guarantee the range was indeed reclaimed but I am not sure we want to provide such a strong semantic because it can limit future reclaim optimizations. To me MADV_HUGEPAGE_COLLAPSE sounds like the easiest way forward. -- Michal Hocko SUSE Labs