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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99552C433F5 for ; Mon, 22 Nov 2021 08:33:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14EFD6B0071; Mon, 22 Nov 2021 03:32:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1002A6B0072; Mon, 22 Nov 2021 03:32:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F09BE6B0073; Mon, 22 Nov 2021 03:32:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0002.hostedemail.com [216.40.44.2]) by kanga.kvack.org (Postfix) with ESMTP id E1EA36B0071 for ; Mon, 22 Nov 2021 03:32:45 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A465F805CA for ; Mon, 22 Nov 2021 08:32:35 +0000 (UTC) X-FDA: 78835899870.24.AEC9887 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 898A15000316 for ; Mon, 22 Nov 2021 08:32:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637569954; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=77VMvTxzwRC+gYmX0HR5hhwgDOQIbvQTIt2pA/Ulf5c=; b=A/HlY11nAgI05OLDU87EocBk0I2V4Q5dGjwSUAo6SgEi4hJfl5ihCL2+R+JOKApGnOQXCT onBozOIg3zaSBrWvEiqwjN7WwodGU7iCgbS9U8MgTAvNysHGjR9NuZx7F+VJXkjc66gy1n Crvfo7Klaq3fPBZb6M/XhmsYoyHtGyo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-548-Dbgw34FZMY-UXnlQCG4b9g-1; Mon, 22 Nov 2021 03:32:31 -0500 X-MC-Unique: Dbgw34FZMY-UXnlQCG4b9g-1 Received: by mail-wr1-f71.google.com with SMTP id q17-20020adff791000000b00183e734ba48so2889796wrp.8 for ; Mon, 22 Nov 2021 00:32:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=77VMvTxzwRC+gYmX0HR5hhwgDOQIbvQTIt2pA/Ulf5c=; b=zl0J+yXWUmy/PiVimGqmat/P6TJHS9NaJKFIXt8Sy4m8R2sVnpz30gU2kioBcJiRV2 j5Zr29h6bxazteorXys9N8LLE7fgW0vrnjsWOCSxXqcnAybJBr5X/iRVT60+2v3V7zuX NGMnYyC1/B6cFEGPjPBkiDc5YU1e8gbFGuaZn0TrpG69ztVxMan0F5bnxshrUu4zHFeD LPfR5LBPhqX2CIcmt2BTKtNNtsTIeZB5e6tf5AC6pPeXhPGnkbl7HtCrXwEIp6Tpwmdg eFl+0TuLhA9mFkthsBLn8qmESA6j/lSs7zz8yxyERKSSOzSqYVIpMwx21weuUjMh4xOx LdpA== X-Gm-Message-State: AOAM5332VJgoX+LArZVdrVbucYnWbDngSLcAxdSQZTUbqs2UHgBr1GQ7 bceGnkGgiC6sR3DMZLzTkKrKCG+T1O0tXP6BFAWLYI7geFuoAFs8L7nU8P0aIfWM7+0k1wCTpIn YoQpZHjr4Wbs= X-Received: by 2002:adf:d1e2:: with SMTP id g2mr34963378wrd.179.1637569950674; Mon, 22 Nov 2021 00:32:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzlQGMN8EdWpL4xofJzq9cQaXxgcFE6A3P7/UDUjYb0RO8zPG1rlyDDlLKC7piWGz2mwaXTzA== X-Received: by 2002:adf:d1e2:: with SMTP id g2mr34963351wrd.179.1637569950475; Mon, 22 Nov 2021 00:32:30 -0800 (PST) Received: from [192.168.3.132] (p5b0c667b.dip0.t-ipconnect.de. [91.12.102.123]) by smtp.gmail.com with ESMTPSA id t8sm9617936wmq.32.2021.11.22.00.32.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Nov 2021 00:32:30 -0800 (PST) Message-ID: <25b36a5c-5bbd-5423-0c67-05cd6c1432a7@redhat.com> Date: Mon, 22 Nov 2021 09:32:29 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Shakeel Butt , "Kirill A . Shutemov" , Yang Shi , Zi Yan , Matthew Wilcox Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20211120201230.920082-1-shakeelb@google.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] mm: split thp synchronously on MADV_DONTNEED In-Reply-To: <20211120201230.920082-1-shakeelb@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 898A15000316 X-Stat-Signature: fq3edegmf85uczkkt8u7wfd7e9fab8m9 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="A/HlY11n"; spf=none (imf04.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1637569952-4248 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 20.11.21 21:12, Shakeel Butt wrote: > Many applications do sophisticated management of their heap memory for > better performance but with low cost. We have a bunch of such > applications running on our production and examples include caching and > data storage services. These applications keep their hot data on the > THPs for better performance and release the cold data through > MADV_DONTNEED to keep the memory cost low. > > The kernel defers the split and release of THPs until there is memory > pressure. This causes complicates the memory management of these > sophisticated applications which then needs to look into low level > kernel handling of THPs to better gauge their headroom for expansion. Can you elaborate a bit on that point? What exactly does such an application do? I would have assumed that it's mostly transparent for applications. > In > addition these applications are very latency sensitive and would prefer > to not face memory reclaim due to non-deterministic nature of reclaim. That makes sense. > > This patch let such applications not worry about the low level handling > of THPs in the kernel and splits the THPs synchronously on > MADV_DONTNEED. The main user I'm concerned about is virtio-balloon, which ends up discarding VM memory via MADV_DONTNEED when inflating the balloon in the guest in 4k granularity, but also during "free page reporting" continuously when e.g., a 2MiB page becomes free in the guest. We want both activities to be fast, and especially during "free page reporting", to defer any heavy work. Do we have a performance evaluation how much overhead is added e.g., for a single 4k MADV_DONTNEED call on a THP or on a MADV_DONTNEED call that covers the whole THP? -- Thanks, David / dhildenb