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 4D63ED5CCB3 for ; Wed, 30 Oct 2024 15:15:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CCBB38E0009; Wed, 30 Oct 2024 11:15:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C79838E0001; Wed, 30 Oct 2024 11:15:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AF4678E0009; Wed, 30 Oct 2024 11:15:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 8DE6B8E0001 for ; Wed, 30 Oct 2024 11:15:28 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 589861C40A7 for ; Wed, 30 Oct 2024 15:15:28 +0000 (UTC) X-FDA: 82730616234.01.531E606 Received: from mail-ed1-f51.google.com (mail-ed1-f51.google.com [209.85.208.51]) by imf21.hostedemail.com (Postfix) with ESMTP id ED95D1C001A for ; Wed, 30 Oct 2024 15:14:36 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=Nc+qnRi2; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730301246; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7mXV62pgMZbmaqYrc2CINf4sAWYHtBW5gtgN0SFvCuQ=; b=RhQyYCmssQvyB978CTJ2HK6KL1tTPscXbmPmiNmB9ZYTSlIcCAayfGedUiIrZW5eOtt6bx cPzRiXrnkX35eGjvuxHDQTQOhC+nnmqOtt4+8ndtZrlCTZOV1BNJyaT8SlPJqvjKjowPK1 J5Gqra0trYg7O807Bmlin6m3CDsLxfM= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b=Nc+qnRi2; spf=pass (imf21.hostedemail.com: domain of mhocko@suse.com designates 209.85.208.51 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730301246; a=rsa-sha256; cv=none; b=2oaV7DKxm2rzsImC3oA9VwZ7L2mJjapBKb/GbIrRDxKbPs+pUAI0BuBY4ozKN/m7nbdmUe cXmGGhQ+zmjvc32nW9mkX5cVPvJbjlextEoA3S2d+qh6Q8S5o4XgcQL6/qXB3v9DHlNhKN Q64Ac9liuPM04QEl6VhzhIvnlv+LK/o= Received: by mail-ed1-f51.google.com with SMTP id 4fb4d7f45d1cf-5c97c7852e8so88a12.1 for ; Wed, 30 Oct 2024 08:15:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1730301325; x=1730906125; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7mXV62pgMZbmaqYrc2CINf4sAWYHtBW5gtgN0SFvCuQ=; b=Nc+qnRi2XesxQZ/pvJ7LXDC0WQyWhhRGfg/kp5dTDcMGCqUDebf8Gu80AyhQJ7IjbX em72wa3zr/kKclFvhVEQLRK4lJxIWectdVnMSQgKm9SCrZoLvF/sRtb+XcEYBu6a9DcP RV9Yxnosi6hTOSVBx+GCz+1l5sTzwjiYJB9Nhzwpw05qZL+ugk4DbXNoUcO0kv9chSp8 yUJvGrhTxrqy1/iODCmrVPb0ksenibV/eEfPEmDcDJCLEjSQQ1hrkYoHyHueJrbc0Y7t d9i8Vt1ITXHF35fqNu88wHM/p6rZgO1luCGa5im1+lJ4iZzUi/bo8Le44ePUimHPnUyT pFRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730301325; x=1730906125; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7mXV62pgMZbmaqYrc2CINf4sAWYHtBW5gtgN0SFvCuQ=; b=ExJ13pvCwy73aDjFgrXELoVDzRap6+NveXEZBu33UBDQtLiP3EyCzgjx0p75FFYUxp 3t2xgAE+6UYRAS5Y3PEvFMy4DnxUHch2fZ8zou3EBTcOUUIleoCQiHfbjd+9a0bIm6SG /RDWfQw+dK8rHv2FKaC4BUNUuM907ZkKIyXt4NO50qAFLTPn6mB9rNI7rq3Cdt19I0j5 dgigcn0A2z3Wqb7gt3HLc04kOYJLCSFVG7fx7wNFaa4B7Ztvub1qJvKVSgIoAiXP5w3c bpZzR4Kq548/ytYuNdUqSHi9X9OICWGTq8+AGXKfTa/R24Kbvflc2ja6tRfLA2HWKb+T DGEQ== X-Forwarded-Encrypted: i=1; AJvYcCVZYBpeaJhilIXlQkfSn1uZKhdJL/jt6cGYdJ/7z2OjdOITyx4qCuFyiy+J5HauzzoCXm1SfFwggw==@kvack.org X-Gm-Message-State: AOJu0Yx/23zlGHKxePmwa2YIDK25jmATaIFTsFXz/66Cr3WBW1S+6Wdt MzLb5Xso1y/ymm1q25oAV3bvlNw1oQ/JQxyvszNYadiMKWReB7NTghtYAdTH1y1n/B0DOUaX4EI 8 X-Google-Smtp-Source: AGHT+IGjLjC5WVGAkUHRu5xNuEkhAwUHz0t+DNaa+GRia2twxV7czGC15dNpQlzuzVDPwmh3J3fQYg== X-Received: by 2002:a05:6402:350b:b0:5ca:193a:8b5a with SMTP id 4fb4d7f45d1cf-5cbbf8d84a8mr11804108a12.21.1730301324548; Wed, 30 Oct 2024 08:15:24 -0700 (PDT) Received: from localhost (109-81-81-105.rct.o2.cz. [109.81.81.105]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5cbb629cdb7sm4809120a12.28.2024.10.30.08.15.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Oct 2024 08:15:24 -0700 (PDT) Date: Wed, 30 Oct 2024 16:15:23 +0100 From: Michal Hocko To: Gutierrez Asier Cc: akpm@linux-foundation.org, david@redhat.com, ryan.roberts@arm.com, baohua@kernel.org, willy@infradead.org, peterx@redhat.com, hannes@cmpxchg.org, hocko@kernel.org, roman.gushchin@linux.dev, shakeel.butt@linux.dev, muchun.song@linux.dev, cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stepanov.anatoly@huawei.com, alexander.kozhevnikov@huawei-partners.com, guohanjun@huawei.com, weiyongjun1@huawei.com, wangkefeng.wang@huawei.com, judy.chenhui@huawei.com, yusongping@huawei.com, artem.kuzin@huawei.com, kang.sun@huawei.com Subject: Re: [RFC PATCH 0/3] Cgroup-based THP control Message-ID: References: <20241030083311.965933-1-gutierrez.asier@huawei-partners.com> <770bf300-1dbb-42fc-8958-b9307486178e@huawei-partners.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: ED95D1C001A X-Stat-Signature: foxftn7ejuuhw9jb4ueq5rsxfhtnyin9 X-HE-Tag: 1730301276-804121 X-HE-Meta: U2FsdGVkX1/u7t/ULIPIO73QIQKa+dY7MfJFh/KOys6OiV7J1q/2wsg+OZjhjb+R3ODvIb7IBGgwpJv+Hg0AvDRBNpR69OYgGQ/xxrv4tFu7K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82by+FNrenxhklR+7k0tQBqZaJfichElfUwBz1kj7tW1LsS44Iuy4Gs3pn2qhCT4YptUO0KqkIWmJiDJlKLbEdISNjTBsv0HL6hWJ6C7J6V8ZHYQ6N3dnoBEOMZjDfq1DBEmqiTuyH/39X2d2uMsDynx9XwjPXEc9rXGvmaQdO7ovkg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 Wed 30-10-24 17:58:04, Gutierrez Asier wrote: > > > On 10/30/2024 4:27 PM, Michal Hocko wrote: > > On Wed 30-10-24 15:51:00, Gutierrez Asier wrote: > >> > >> > >> On 10/30/2024 11:38 AM, Michal Hocko wrote: > >>> On Wed 30-10-24 16:33:08, gutierrez.asier@huawei-partners.com wrote: > >>>> From: Asier Gutierrez > >>>> > >>>> Currently THP modes are set globally. It can be an overkill if only some > >>>> specific app/set of apps need to get benefits from THP usage. Moreover, various > >>>> apps might need different THP settings. Here we propose a cgroup-based THP > >>>> control mechanism. > >>>> > >>>> THP interface is added to memory cgroup subsystem. Existing global THP control > >>>> semantics is supported for backward compatibility. When THP modes are set > >>>> globally all the changes are propagated to memory cgroups. However, when a > >>>> particular cgroup changes its THP policy, the global THP policy in sysfs remains > >>>> the same. > >>> > >>> Do you have any specific examples where this would be benefitial? > >> > >> Now we're mostly focused on database scenarios (MySQL, Redis). > > > > That seems to be more process than workload oriented. Why the existing > > per-process tuning doesn't work? > > > > [...] > > 1st Point > > We're trying to provide a transparent mechanism, but all the existing per-process > methods require to modify an app itself (MADV_HUGE, MADV_COLLAPSE, hugetlbfs) There is also prctl to define per-process policy. We currently have means to disable THP for the process to override the defeault behavior. That would be mostly transparent for the application. You have not really answered a more fundamental question though. Why the THP behavior should be at the cgroup scope? From a practical POV that would represent containers which are a mixed bag of applications to support the workload. Why does the same THP policy apply to all of them? Doesn't this make the sub-optimal global behavior the same on the cgroup level when some parts will benefit while others will not? > Moreover we're using file-backed THPs too (for .text mostly), which make it for > user-space developers even more complicated. > > >>>> Child cgroups inherit THP settings from parent cgroup upon creation. Particular > >>>> cgroup mode changes aren't propagated to child cgroups. > >>> > >>> So this breaks hierarchical property, doesn't it? In other words if a > >>> parent cgroup would like to enforce a certain policy to all descendants > >>> then this is not really possible. > >> > >> The first idea was to have some flexibility when changing THP policies. > >> > >> I will submit a new patch set which will enforce the cgroup hierarchy and change all > >> the children recursively. > > > > What is the expected semantics then? > > 2nd point (on semantics) > 1. Children inherit the THP policy upon creation > 2. Parent's policy changes are propagated to all the children > 3. Children can set the policy independently So if the parent decides that none of the children should be using THP they can override that so the tuning at parent has no imperative control. This is breaking hierarchical property that is expected from cgroup control files. -- Michal Hocko SUSE Labs