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 E3D20C433E0 for ; Wed, 17 Jun 2020 22:03:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A5B942082F for ; Wed, 17 Jun 2020 22:03:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=nitingupta.dev header.i=@nitingupta.dev header.b="hxvCNKKp" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5B942082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=nitingupta.dev Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2E5726B0002; Wed, 17 Jun 2020 18:03:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 296246B0005; Wed, 17 Jun 2020 18:03:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1859F6B0006; Wed, 17 Jun 2020 18:03:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id F1B956B0002 for ; Wed, 17 Jun 2020 18:03:04 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 68D12824556B for ; Wed, 17 Jun 2020 22:03:04 +0000 (UTC) X-FDA: 76940079888.19.trick36_51099e726e0b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 2F1F51AD1B9 for ; Wed, 17 Jun 2020 22:03:04 +0000 (UTC) X-HE-Tag: trick36_51099e726e0b X-Filterd-Recvd-Size: 5835 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 17 Jun 2020 22:03:03 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id 35so1573573ple.0 for ; Wed, 17 Jun 2020 15:03:03 -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=XJebA9hbhe0IqIFyKw0IyjzVknA3ASvBe/jO7MexoR7wLiLoS0eVZh/W16L0t6ZtF6 f0Wga/TkvFxqVzYsAj/NYHxIJBzOdOR51rO3JydmUH945aU91tuCwUHwpiMWJB7qb8L6 ilLR85xkcu+XdqAWY9RxlWzZq9miiIdnxqZX0qXAM1z4HvIY5JriXG1LYH4Uc8ZU1NJ9 T4NmyDvu/CMKxlmp8DMHA2NUQ+T6Nq2sdK7k68WyxgmV+kk8g7Sf6Eg4IZgJ4FvifgQh mzFJYWkHMkvVyL1mRr7XgCW4PVuHdh+YwFQhZd/NWiWfFXNYy/cz/QD43phTdlfKeOCb IBNQ== X-Gm-Message-State: AOAM530R4UGLeI/mkx9iLJq6Apcs2+BW9jH76qAZVt0UExdpbLennE+p WjXZ8Ax0MpPpsQso7XaamIpK1w== 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 X-Rspamd-Queue-Id: 2F1F51AD1B9 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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