Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp822433ybt; Wed, 17 Jun 2020 15:07:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU71pGxRBlBlIwLea84Kzs2M4GnhIG2unG6pVp7GpVhFPNTDxxjSTOj/Lik4pOrf97qqgx X-Received: by 2002:a17:906:71ca:: with SMTP id i10mr1228169ejk.550.1592431657513; Wed, 17 Jun 2020 15:07:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592431657; cv=none; d=google.com; s=arc-20160816; b=cb1B1aimqgtAOopBQkUWlpGdzKkRPpbDDzGACa3y5aQ/h6mR7LfkFIZ6RNG11wzqks /GgsCZR98jrnrks6iZEZJie/fjoLQDWqLdpU45o0ZNKL/CkalgdaxrU3q4eE8bHgt3/D p6VFWLpQzhtQeM+IBZylyHskRERfJv05Tdj0rSYAMngXJmldhFSCOgl7hA9h8mlwh1Xg 2SY2nLWc7juXY7+8OUsQNiwuvJGKoZhXAmUO7oa1/29wNH2nlPobdvlVRhbC8YTAPfNX 95KmtX2Un6s/KHG6Lxh9mrRbb/ntS39g+fDD/Ggqtvjq5ycaSMsHQiRqE9WTQDs0ZYh0 NcTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=kqcGCha/RkSYtgLEEH/pj3ontPR0wERiXeW1+vfpoSk=; b=kolKFIMF3mDMci+TSIYhYDUrE4SLJKgcSIR2E1skUt4rFyLhjrv0C5qX3Doe7B04EI nZxDWRCx0jg+MG/jPp/pVyJp7qQQMpfAmeX8RUbcNYFRfFNJIghUwdpod4oyK68eGIY4 DqKT1QysNFjxA8HhXpHyZTDgfM48KdxKS2fBEfa862iq768CO50P/o9PDm7TSylx6Pr8 QRqcz64FZ5PYSAKoG/bJVuRv/+yrVv4umTRSjl/Fr5jrQddBmdi2gfQGMeYJa5W0tdPG Kv2442Ynk0KhKK4cFbXK2ggk9AFZvq2R/bu0icl3nV8zZGPtnMnl5009Tf4C2f7hsqoG cmOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nitingupta.dev header.s=google header.b=hxvCNKKp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb14si727131edb.161.2020.06.17.15.07.14; Wed, 17 Jun 2020 15:07:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nitingupta.dev header.s=google header.b=hxvCNKKp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727039AbgFQWDD (ORCPT + 99 others); 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-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