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 6BB97C5B552 for ; Tue, 10 Jun 2025 16:00:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0FC986B0088; Tue, 10 Jun 2025 12:00:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0D4FE6B0089; Tue, 10 Jun 2025 12:00:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F2CA46B0092; Tue, 10 Jun 2025 12:00:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id CFA586B0088 for ; Tue, 10 Jun 2025 12:00:52 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 7C7595B8D7 for ; Tue, 10 Jun 2025 16:00:52 +0000 (UTC) X-FDA: 83539954344.22.1889B18 Received: from mail-ej1-f42.google.com (mail-ej1-f42.google.com [209.85.218.42]) by imf22.hostedemail.com (Postfix) with ESMTP id 76184C000C for ; Tue, 10 Jun 2025 16:00:50 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=F08qmx96; spf=pass (imf22.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749571250; h=from:from:sender: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:dkim-signature; bh=GQWLfYp5I1ceHGB1pz5r/aQqCgyzKtMLW4swedU4Rqo=; b=AegKOptItg7c8/sZ5Dd9ZfW3BcBUJOUEUpDmx7Sow890zKNO7kNJdZ5mk5ot9O8EuVddqe 9uxl+Pq4JJZMzrldEyKTAruGCCf0KKevR0EKB9FLA8U+kv/W0m40cM6SyHowN84j53RxQp myIHudYS+OrqYQBEyh9Xo2fht1CPOsM= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=F08qmx96; spf=pass (imf22.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.218.42 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749571250; a=rsa-sha256; cv=none; b=LqRbN5VrlyhZs5wQyVeT4Es4RJ38PK8bSeUyyXpsnBuBOhrogt4NDhsUtAfAf6fIj84lOl b78nFWE+4oD3MI6JGwx5CwJrXlNIkBQCgYy/Yl73b3L6M05Z0IzM11a3qdD3KuLQKkYQ0B vBbyBSoQK6ztbMU7U78oEwjF9cXUXDQ= Received: by mail-ej1-f42.google.com with SMTP id a640c23a62f3a-ade4679fba7so518509666b.2 for ; Tue, 10 Jun 2025 09:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749571249; x=1750176049; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=GQWLfYp5I1ceHGB1pz5r/aQqCgyzKtMLW4swedU4Rqo=; b=F08qmx96SeQMJknXeydZyciQdcLmxdwyEZLBze+Q9v47HBUwWCzMPiQOZ8VJ5RJBLu 0V5mG39cgCb7ZMnSdb1tzm2qoNAM+mpiQbZaf81jO89fqkPCjUk6MCk9me83gk2mbqqk VGFvMTsIjjA4S/LChwLo2fww+WLFcB6sh+wDm7qmEdEwX8xlFCkgK/5NN6zo8y43tDc5 /izXVr5tAnxq7dlMHfHbez3qNYVxuHgSOHnvy4E7G0BGYHzdTfCYXiytDYwdG6zUKQ85 W0Z8ciDL7lRAhlRtgCGBblyOukLSukSi84Ev156SDljk0vE5Qn7OXx3ntZXkGbgbMJpt YotA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749571249; x=1750176049; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=GQWLfYp5I1ceHGB1pz5r/aQqCgyzKtMLW4swedU4Rqo=; b=VhIuYwaerj4B87HpqOV/w9LNq8l2/edZIU0aowjNO0Jv/lXR9NEKgYqDEQCxBVJxgL y8SWaDTWf8ur3T0kfDd1YreVzQtPRjSP2Sovwid/jT0ZR3MfGnJmj8Ov7A44HH6aQsBx U7vDvY+FAbLJIMUBx4LR032EQ/bsBlKAPjibiYhIHquiVoGkDn3vyF9f8RdDy9qu2ppF oGUM59ps5mPNComreoRFFKkV9fkd5ITZVf1kuQg3fIGm0jOzU1V6McViv6DouRHdL8IQ JjPmKXXKze0B8rBLTr3ZPdbKifuvvda28ujdaOIW/hgSwiJL6ggKUvWAFln9z1TNf5em za5Q== X-Forwarded-Encrypted: i=1; AJvYcCVdC1UwRamvcAYBqRDBV8P3OeJPjz9WV/Lfrs+JIea8spYjLLUHSRqYvV0VH18c6xO6KBJzej+1fw==@kvack.org X-Gm-Message-State: AOJu0YwVbX6lALd/44rcRZIn4MUsCGLdrfvetB5NIBj55WFFgTFA7cJ/ az/JPMll/DHWK7dQL2Sqto5/qVWF2NulFERi0WKCIzXHZpNc99/aAl+d X-Gm-Gg: ASbGncsEvS/PDJEi3lwEtJaEmyOf1ElbwWc1ex7h3nRbZDvXGltJuvbXnquWij/SdiN PhA+u1nkoGQ62QHhJ4irG+8x7YXwiCTKis6OYWTvQgYAzacWjfmUvmQ3JCGKKgvt1xnmbF0k2YQ sbsAoMFLRp6E/ePgG75iiVEcdO0l7cYrGLzVufqgDRKWNasG9PYZy/4GsHpheDhXZt4CVcuEl/y zisdc8HU3KcucZQ4HxMOpQYI+VvXP8sr4HNSSnqRqIilDOGJPm2KdFsOx5w+53L7ooXg/apGIde YRcht/9qgbbgmH7ZexEQoGoFLYB14lBPxD0uI2yHNQ1tRi6DDZwdNIK8VK+j9xuGrB4JRKyBQCz f1qB6K+l7967KXP78/A+1FcMCHRgkDuBNSJsgzGYw6xwzHiv4 X-Google-Smtp-Source: AGHT+IHKS0te2rXw07wqy+zzfCiWuP4078dBifqY5s3F/kkc1JYi2TIxO7c+n7JrTLgvZbBM0fwI2g== X-Received: by 2002:a17:907:6d0c:b0:ad8:8c09:a51a with SMTP id a640c23a62f3a-ade1aa0fb2cmr1690627766b.4.1749571248678; Tue, 10 Jun 2025 09:00:48 -0700 (PDT) Received: from ?IPV6:2a03:83e0:1126:4:c2f:a34:6718:ee1d? ([2620:10d:c092:500::7:b9b7]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ade1db57856sm746559866b.63.2025.06.10.09.00.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Jun 2025 09:00:48 -0700 (PDT) Message-ID: <8c762435-f5d8-4366-84de-308c8280ff3d@gmail.com> Date: Tue, 10 Jun 2025 17:00:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [DISCUSSION] proposed mctl() API To: Matthew Wilcox Cc: Lorenzo Stoakes , David Hildenbrand , Andrew Morton , Shakeel Butt , "Liam R . Howlett" , Vlastimil Babka , Jann Horn , Arnd Bergmann , Christian Brauner , SeongJae Park , Mike Rapoport , Johannes Weiner , Barry Song <21cnbao@gmail.com>, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Pedro Falcato References: <85778a76-7dc8-4ea8-8827-acb45f74ee05@lucifer.local> <2fd7f80c-2b13-4478-900a-d65547586db3@gmail.com> Content-Language: en-US From: Usama Arif In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 76184C000C X-Rspamd-Server: rspam03 X-Rspam-User: X-Stat-Signature: if956mbm39nzmo8n6xr47qf3p4k3fn39 X-HE-Tag: 1749571250-694784 X-HE-Meta: U2FsdGVkX18wH6RFWQvZpWpHq71rfurTuQ99zxGXadrgOkoS5gOX0K4FkQMURkZw0zxTaN1TUd4FS2sWfojebKGFtCOrEDc8GHsUCmmpLBxr7qwdmyZPMhi02BIPg5LAGg7meXlosJrTsyqhop9XoyGNikw06sDMOuhsjvPfmUWpI1G3HxYJfF8HhMNJZcEO0OGSXRx5Oy8iwGUD7BOTRrXXKRB7msYl/4B/9azS3WoFScR7b5E5A9REpPmsEaVMaxRDx+E8okmrAbUGWr3C8b/bl/d47o0sxe1QUJFb4Qeqd0ar4ucoytvdI8XOz0V0+tbQAm77dIEFd9nGJUSiMfE49LUJw0GntkhwxeIdc+JL757Wf9J5MiMekUdukgI5NAygZnPd0CYQ2eiN45GvqPjJiE7/z1/6RKEIi97aLeAU5gGfCI31HLnidYQIJV1nTbgH6WmCWk5swRWTB9EM4BSE+5aZlLkI2zcNMlx1vP0GHo47LdaKhCaPgi2M9xrJEiHr5MtbIoZ/on1yQCYa/z+meWhgc+EKv4NaL2i6sTdyhHxkRWJFllntDf+NlvP3+XLs0N/dyNnHnhr1WPqf1IfzGViM3eqjZ7bdhewI0efB/qA5xrB9hM8TuN0OZ8XWHeWkAvYwAMxUagSHpXUc1rfGXsxH33wugvkoZsMgPGRzhoI6cSklDESrWRz8F2ia4a8jTHCyu+EpkYfrPjLI3kBK7INRE9ajSLBVaHAPGfasTQ1RSLmNMBYI6RqwbD1DuE0xADK19En0TedD/2QHScfzHtDmEomYE3bn0uv+T0WgiCSm0BaMoIKhFpvMmuo7yKX08A4FTCqezmaMIb7DraUbpnvuORqSGYLg1R8WosVb7Yax5+l1i6qyGpkkPvle7cANMr5US3Yoh7OjkEPJpCly+6qyJNL0wj7zfwcylcYLtdg03HNSayQ4Wk2Z6fc2taCb+7F9VYBPraiizHN oOvgHAWR 09BDAy8PM0oMTyOIzlZ6fNG70OboZ3ZAVf5hN55Cwxw5ZQTtbStjMnpUCOttXjGtu47sdFqMvjZ1ozDeidunn73RGI2Kjd0NV35SRflTJ2cjpHS8OmIc2FuZUPNie0/EJY6BsjUM5CGNByQzCsqvyrP1cFiVLIVOM9ezwGUcklCrsQ5Xq34FcFn0BobGGllzLcmeM0agGfrgfe8ce62QEG7d9avHMa2mDCFBZqeXbDTdK+vomGdl5kWmB9VW15cdSkAhLyS3xcfOwygfRe+9+3ZmhzGhA+hpZAJhRS5kUTMhrdttwrOeqng0Gc9ySCZXOLhPSpwXh5ELksi2axGyUgyTQYrf9S2BHLaY0HK7ttxAkd0BZLFq6djQ/a+aPnMUEknKEIG66KYq7Gr5kogBBmHP4F7frRaGeFO10LSsJFL9aE6sxXnS8iFyAs3TcGJVL2zv0kLM22bGwUcjJfQWRRjL6ZA== 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: List-Subscribe: List-Unsubscribe: On 10/06/2025 16:46, Matthew Wilcox wrote: > On Tue, Jun 10, 2025 at 04:30:43PM +0100, Usama Arif wrote: >> If we have 2 workloads on the same server, For e.g. one is database where THPs >> just dont do well, but the other one is AI where THPs do really well. How >> will the kernel monitor that the database workload is performing worse >> and the AI one isnt? > > It can monitor the allocation/access patterns and see who's getting > the benefit. The two workloads are in competition for memory, and > we can tell which pages are hot and which cold. > > And I don't believe it's a binary anyway. I bet there are some > allocations where the database benefits from having THPs (I mean, I know > a database which invented the entire hugetlbfs subsystem so it could > use PMD entries and avoid one layer of TLB misses!) > Sure, but this is just an example. Workload owners are not going to spend time trying to see how each allocation works and if its hot, they put it in hugetlbfs. Ofcourse hugetlbfs has its own drawbacks of reserving pages. This is one of the reasons that we have THPs. But they will try THPs. i.e. if they see performance benefits from just turning a knob, they will take it otherwise leave it. >> I added THP shrinker to hopefully try and do this automatically, and it does >> really help. But unfortunately it is not a complete solution. >> There are severely memory bound workloads where even a tiny increase >> in memory will lead to an OOM. And if you colocate the container thats running >> that workload with one in which we will benefit with THPs, we unfortunately >> can't just rely on the system doing the right thing. > > Then maybe THP aren't for you. If your workloads are this sensitive, > perhaps you should be using a mechanism which gives you complete control > like hugetlbfs. Yes, completely agree, THPs aren't for the workloads that are this sensitive. But that's why we need this, to disable it for them if the global policy is always, or enable it on other services that are not sensitive and benefit from THPs if the global policy is madvise. We have to keep in mind that these workloads will be colocated on the same server. and hugetlbfs isnt transparent enough.. :)