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=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 1775AC433DF for ; Wed, 17 Jun 2020 22:03:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF4CC21548 for ; Wed, 17 Jun 2020 22:03:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nitingupta.dev header.i=@nitingupta.dev header.b="hxvCNKKp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727060AbgFQWDD (ORCPT ); Wed, 17 Jun 2020 18:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726758AbgFQWDD (ORCPT ); Wed, 17 Jun 2020 18:03:03 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1ED4C06174E for ; Wed, 17 Jun 2020 15:03:02 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id g12so1550264pll.10 for ; Wed, 17 Jun 2020 15:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nitingupta.dev; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kqcGCha/RkSYtgLEEH/pj3ontPR0wERiXeW1+vfpoSk=; b=hxvCNKKpOBh5EWbAEWTfILZT1LVkUjqhOSwh+k4CD7PiFhYlD8cPmHeeaUODZbCvTO fzBeqH+CDB1yFWwULOCwZblxoXsce9TtZhr3sDUUw9Z8sotxZu7w3CN9wtyfIJPkBVBf 0WygPww4jLYPMEYUVyboxubvlhCVOAdtezpzFH/DbO/Yn8LogmhkqtaFxNAsvyGvFj+e 1cCxONkOpcG5789UFBnpZRjy7tjP1gptvWvu4weUU4rFw5ImewN6u6FuKE1QVLAzZm1z 4MfcJ3YcOI+sKnIMYGetbJcL9Nd0o2RIzLCQEX55abDxsMhxq6tubYRzDO+hjpRvicv4 lSzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kqcGCha/RkSYtgLEEH/pj3ontPR0wERiXeW1+vfpoSk=; b=Tz/Sxzt8ON4lpXgFfBFgbvzcy60ou82VhTOiDNvPnuGBYv5T/nkrd+Nh3ylxJejb9c 80fIFjW4qVZipI8T8MdWGQA/CMSBvKbXOD5lsA6PbBM/oL4o2xxGr4OeytVk89dJRv9c 6/dCQ/wwILOTzM2m+SyE8SfAMmNveJCi+eshdSkatQOQaNo5lqRTeIMce8alCs8iNYbt MJbUu5YLiqFfvFL6qnNqBQ6kaTBKmg0if+P4g93rvcGnkmLA23acjll/R1ZDA1xchpN4 p8Sin0iZVBxMPeDU6V06oUqnW3J6vywZFAvCBndTpiEPdm5xKDn6lAQQ41e91Od4AgEF Lp+w== X-Gm-Message-State: AOAM5319Z0zoVtK0nY9D2kbqKI2ua5HyV+0lt516KHp+ONWTB9PwBzzk cjaTw7wdZCc3rfz1Lx1l3Md+Xg== X-Google-Smtp-Source: ABdhPJwVfKhrTfOk577kqNSuLA7cVaLo/HOLePD8p7+peaJ4nZKPanbWSN5FlKuXAjYWJqAfX3lFrw== X-Received: by 2002:a17:90a:d104:: with SMTP id l4mr1077178pju.65.1592431382409; Wed, 17 Jun 2020 15:03:02 -0700 (PDT) Received: from ?IPv6:2601:646:9302:1050:44b6:a386:5b78:5708? ([2601:646:9302:1050:44b6:a386:5b78:5708]) by smtp.gmail.com with ESMTPSA id t76sm744480pfc.220.2020.06.17.15.03.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 17 Jun 2020 15:03:01 -0700 (PDT) Subject: Re: [PATCH v8] mm: Proactive compaction To: Andrew Morton , Nitin Gupta Cc: Vlastimil Babka , Khalid Aziz , Oleksandr Natalenko , Michal Hocko , Mel Gorman , Matthew Wilcox , Mike Kravetz , Joonsoo Kim , David Rientjes , linux-kernel , linux-mm , Linux API References: <20200616204527.19185-1-nigupta@nvidia.com> <20200617135312.4f395479454c55a8d021b023@linux-foundation.org> From: Nitin Gupta Message-ID: <10f8a7c1-dc1f-532b-7ef7-d37b04334fbe@nitingupta.dev> Date: Wed, 17 Jun 2020 15:02:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200617135312.4f395479454c55a8d021b023@linux-foundation.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/17/20 1:53 PM, Andrew Morton wrote: > On Tue, 16 Jun 2020 13:45:27 -0700 Nitin Gupta wrote: > >> For some applications, we need to allocate almost all memory as >> hugepages. However, on a running system, higher-order allocations can >> fail if the memory is fragmented. Linux kernel currently does on-demand >> compaction as we request more hugepages, but this style of compaction >> incurs very high latency. Experiments with one-time full memory >> compaction (followed by hugepage allocations) show that kernel is able >> to restore a highly fragmented memory state to a fairly compacted memory >> state within <1 sec for a 32G system. Such data suggests that a more >> proactive compaction can help us allocate a large fraction of memory as >> hugepages keeping allocation latencies low. >> >> ... >> > > All looks straightforward to me and easy to disable if it goes wrong. > > All the hard-coded magic numbers are a worry, but such is life. > > One teeny complaint: > >> >> ... >> >> @@ -2650,12 +2801,34 @@ static int kcompactd(void *p) >> unsigned long pflags; >> >> trace_mm_compaction_kcompactd_sleep(pgdat->node_id); >> - wait_event_freezable(pgdat->kcompactd_wait, >> - kcompactd_work_requested(pgdat)); >> + if (wait_event_freezable_timeout(pgdat->kcompactd_wait, >> + kcompactd_work_requested(pgdat), >> + msecs_to_jiffies(HPAGE_FRAG_CHECK_INTERVAL_MSEC))) { >> + >> + psi_memstall_enter(&pflags); >> + kcompactd_do_work(pgdat); >> + psi_memstall_leave(&pflags); >> + continue; >> + } >> >> - psi_memstall_enter(&pflags); >> - kcompactd_do_work(pgdat); >> - psi_memstall_leave(&pflags); >> + /* kcompactd wait timeout */ >> + if (should_proactive_compact_node(pgdat)) { >> + unsigned int prev_score, score; > > Everywhere else, scores have type `int'. Here they are unsigned. How come? > > Would it be better to make these unsigned throughout? I don't think a > score can ever be negative? > The score is always in [0, 100], so yes, it should be unsigned. I will send another patch which fixes this. Thanks, Nitin