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 473CFC02183 for ; Thu, 16 Jan 2025 14:26:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BA071280002; Thu, 16 Jan 2025 09:26:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B4FE6280001; Thu, 16 Jan 2025 09:26:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A174E280002; Thu, 16 Jan 2025 09:26:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 83283280001 for ; Thu, 16 Jan 2025 09:26:13 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id ECA4C45146 for ; Thu, 16 Jan 2025 14:26:12 +0000 (UTC) X-FDA: 83013539784.09.89D6E26 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 799F12000E for ; Thu, 16 Jan 2025 14:26:10 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PQAn1dmf; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1737037570; 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=iKe6KcY8mvA8I/UtecGUiy6u52GdsOnELZoEiMhFOAc=; b=lhPJndVsUGXOMosbMUUjim78TC4x3UA8AbAdGaaSJoxicIqnmAHiUFZCC7DyLQ7WhHoZ7c VQynTmP+WuSGShrABDfHiFAWgDBUlwc/Il7/0uLYjA4aCPzc0hItZ60bDeeIMgiHdkyH4D qqsgCr9o9GhJVms6+ChMNxpy/YRS1ig= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PQAn1dmf; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1737037570; a=rsa-sha256; cv=none; b=olH3gVTFIVZN7Oupit236PnrKKaaukiQlDvonQkpiR+qcUmThBcGL2i/grWIgroMAPqzvY 0mgfssbKSDSiND9bwwW2V0U4GIu5qewgNkkXK8HB0U46rmZjx8DCv4T1bYgsfoYY+NAGV6 5a+42Y3PswjCPXJ3VJuFC8SOgaOti/0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737037569; 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: in-reply-to:in-reply-to:references:references; bh=iKe6KcY8mvA8I/UtecGUiy6u52GdsOnELZoEiMhFOAc=; b=PQAn1dmfMLuqDz9NOgx16mcP+ekLo1hKgBMxVJ25/FcCfM8WXv0gpVDqorT6S1m6XOIkq8 jB1CfVUMEL+l982Ludpjn1v2KkLhsGp+a7koxtstZkjbALoujHST0dJLuOavEidVnSzJoO N260cgVe1yJ0M+AMs4+r0dsDcbW8xRU= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-244-JZMytdGBOBytro9XtyftHg-1; Thu, 16 Jan 2025 09:26:08 -0500 X-MC-Unique: JZMytdGBOBytro9XtyftHg-1 X-Mimecast-MFC-AGG-ID: JZMytdGBOBytro9XtyftHg Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-467b645935fso19338141cf.3 for ; Thu, 16 Jan 2025 06:26:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737037568; x=1737642368; 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=iKe6KcY8mvA8I/UtecGUiy6u52GdsOnELZoEiMhFOAc=; b=SSSpcXlWSnxOO2nAly1Rbxbl2t82JjvSyxzNi0K0sepma//R7m5cDlzrV01BhMelOu yWTJiRuso93jgxQmZAmMGpQrsw5rm/rZB2AJeS+0gqwvv6MMByJKImjMlfX/b3FnMnBM x+u//rmPNAFhM7JYt1agtck50J7IzY77tg0zCjrhBKMp7MfohnCBjDcNW3IBsLf/EwFL 7U6WRbbA4n71cPYrBXDCedLxbxphKg8UJEVUWF2PB0YPzD8NuqyuG9mbuV7uBOUah7RQ RY1hY1Ks+mvRNQ4TgcdeCO1w0yniMi4xPsvLhlu/z6YeiT9YABg6R8gj0qNkTguj5AjT /s6A== X-Gm-Message-State: AOJu0YzIct3ICLOLhGzZvZEe3xjskk3ZYXxPQ+V8NCn+prtKvqQoNYHp zg2CNAB+dSV3e5MjQ7SUKwuhSj/SgKNsZfLEzQfTOlEqygXypfv75oJl/UF6BvO+b504P1FdOrr XCz6cLAoyA9Dc7rnKLmKN2GHA+Uzwn3Pa+IqVgh/KG4+s1wTY X-Gm-Gg: ASbGncud988N0e9EW6w3CWDIlJ/o2AWbWfH46pz9qTelxZvPzQd0G3AzGpeA3+OuShR jpfH/ohwcCNwgjpBYijNYS52dzjhq96LDdrL+r+EpvSb7nEb84wQEaK6I7pKbRVrOf+yXgd92nk 9v0Gp2k2WH1/aUyrVXAHY2vu+NF3+OS+QHjYx/RLJGrGD1XlZKtwsbzKNw6zSzCHC0z6nFKvoPY 8A8QDENT+KRIkhVCk4+eQ1+VmL38lzsDm3CzwJpP4IBDLM42HPHYqzv6j+06mhMj5L7SU5pwabi pNs6vLAX0bydoEPP1Q== X-Received: by 2002:a05:622a:47:b0:467:6226:bfbd with SMTP id d75a77b69052e-46c7108fddamr540431831cf.21.1737037567902; Thu, 16 Jan 2025 06:26:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2zEj7BJCtwai45n40ywW8QXo28hswimXis9xNl5GkP7DD2Ph5Fqhv4GN0l0MBAyJlw1aUQA== X-Received: by 2002:a05:622a:47:b0:467:6226:bfbd with SMTP id d75a77b69052e-46c7108fddamr540431421cf.21.1737037567578; Thu, 16 Jan 2025 06:26:07 -0800 (PST) Received: from x1n (pool-99-254-114-190.cpe.net.cable.rogers.com. [99.254.114.190]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46e102fe43fsm15081cf.26.2025.01.16.06.26.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jan 2025 06:26:06 -0800 (PST) Date: Thu, 16 Jan 2025 09:26:05 -0500 From: Peter Xu To: Oscar Salvador Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Breno Leitao , Rik van Riel , Muchun Song , Naoya Horiguchi , Roman Gushchin , Ackerley Tng , Andrew Morton Subject: Re: [PATCH v2 3/7] mm/hugetlb: Rename avoid_reserve to cow_from_owner Message-ID: References: <20250107204002.2683356-1-peterx@redhat.com> <20250107204002.2683356-4-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: npnsQH9jJ4m3mA325F0wuwQFWF03vUXQIXRRrgfmJGA_1737037568 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 799F12000E X-Stat-Signature: yeimjmxd43etfhsxga7d8hun5rjqq5ja X-HE-Tag: 1737037570-803005 X-HE-Meta: U2FsdGVkX1/UYQwFVx1mtKT6Q4G2VqZq+JMgWXwo58JdWvkr5cOaC6ACbjedKdy8W8XW2KhLQG48JpMm5x9TN4CrW91/T3R96hBQjyt/Ka6ra6AugITMqfa7YSsTmNbuwkoct7u5Sd5olIZhoivZkZ9OQLWOWGeTks+cUQHvQ2+V5bmvvounUdETJYiXkVEQD3BU4QlgmCX9U7sdhVf+RAc+4GjJGx/YbLY6cypA0T6y8JjGO/r2lp6+dI7NvGk4Gd23CYNh9WAqR+0ePPcCra9MdmbxyTPRy7eBwx1pYgizFAIHyPYzlyuJTI/wGM5s1JoS3huSB8J9uqRvln8HR1zCd2z37MRE83DfiIMMBwJ/hSRxxKIHbOhonERSgr9Q38lRrIDGinXngJm03L5unOVADzpE25DEMSJIkkQxH6sOziOqKQVU8MgOkeGfLl6iTFzrlC9RFLHIbyYpRdvCvXHW96Q2BMkSEzDxl12pxfuuqzurqoJRq36TgbBhdZY3h5LSxDsVildzP2clFTQGY7IuRRZVyohMe5HplSN3tARRfyzV8HLPHq0w3o83SMxRXWFy5JHf4Ka9M/6DWTUMy9zmoLT+MIX/tlrA7ssyDILD4p9Tm+XqczjroZem7Jgl2YpJBnmwzxV92Ohm7nl2x104uAHjR+0N1Xo3iXQNCDJ6JFeLbQV7ebJUD2fwIfJWS/Ok68PMgKInqgPzqESp+oz2518rnGbR1I50rI8TJwFBnk0VufRwW0vG9Dnd2h8O5QA5KJbC6WaFIp5X3wosrJWll4qamYuQ/n8jNa9QvtJe0Vwz5GIUTwZyxSDigV31msyngUqU4gi0RoPUg8MRFcNXZEOOkew58HGAcbFIsOHZjoRQ8dDxQMvmoYMNrnWYV7pogss5KXbkAV3ZKxWvUKnK4YdH+9AS4XxqVBgtBH7HW5LSjjCwY0K+zkrUl8A3nAmDHbet93/IS9tJ9Ga jxu62swC aWnTLo2m8F4QQHMyTJhi7Gjz6+L2E5WXCi6XGw65ML/je5zzMmdzYPSlSfFVE1zxTKQiQyjB7tkladvy6HJrAVDbEEzpeNt1/q3DLhefTPYY+gbXhWd9DoJX5lIEThtRfwoGOVj7wi6aNaDEgRxNs/vvVhgBeh1xi7xe4czA/D6enwxJINmmDWjAdEFU9ZbNmAMaUPmpzvL77AxYJWIU8DqFvl3fGn9TThdV3a08P2NM31M8oj4I0KzV10qWno38qgh1PTTJf1BPdm7Bp3tMOt6HSlcoXuX4mupaFgvFTNWHTuDVeNybPl+T6oREbPB1QuDg628Ptg15fvAvHvlp8n8BWPSDLvy5G7BXElqE0OSDan8bca7Z4AthojNbxNtrWALJH47Pp4BKmrxSu5V9ajUXDJwI74NjVmPVevszIKR6mduoziWsVG1xcVRxViY+TmfAZZLbmNzNYBSmngJ3T3Rn4vL9Rra/WIXxREC2q7T+AzIc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000177, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi, Oscar, On Thu, Jan 16, 2025 at 11:15:09AM +0100, Oscar Salvador wrote: > Now, let me see if I get this straight: > > 1) parent maps a hugetlb page, but not yet fault in. > 2) forks, child faults-in the page Agreed until here. > 3) child doesn't have any reservation, when 'cow_from_owner' set to true > we check whether we have a spare hugetlb page to satisfy that When the child fault in, it should trigger the hugetlb CoW fault, in which case it should set 'cow_from_owner' to false (rather than true) always, because it's not a CoW from owner (the child is not an owner). See the check in the fault path: if (is_vma_resv_set(vma, HPAGE_RESV_OWNER) && old_folio != pagecache_folio) cow_from_owner = true; Here I would expect when the child faults, the 1st OWNER check failed. > 4) parent faults in the page > 5) we do not have spare hugetlb pages, so we 'steal' it from the child > with unmap_ref_private. Agreed on 4/5. At last step 5, above check will become true, hence this is the place where the allocation will have cow_from_owner set to true. If we see the difference at step 3/5, that's also exactly why I renamed the variable for the whole stack: it represents this special condition from the top layer (fault) until the allocation layer, saying explicitly when it should be set true (only "cow", from the "owner" not child), rather than a very blurred idea of someone trying to avoid_reserve for whatever reason. The hope is it made that niche path very clear in the allocation path, and it discourage any other user using this flag which can be abuse (and cause the allocation path harder to follow in general). Thanks, -- Peter Xu