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 C6B01C43334 for ; Mon, 20 Jun 2022 08:56:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 382078E0002; Mon, 20 Jun 2022 04:56:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 331D26B0078; Mon, 20 Jun 2022 04:56:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1FAA88E0002; Mon, 20 Jun 2022 04:56:09 -0400 (EDT) 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 0CA0A6B0075 for ; Mon, 20 Jun 2022 04:56:09 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D2FE434521 for ; Mon, 20 Jun 2022 08:56:08 +0000 (UTC) X-FDA: 79598007216.13.065E7F6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 496D4400A1 for ; Mon, 20 Jun 2022 08:56:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655715367; 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=QEyy/6JZbSt5hhSc4lO1WFt1fgnwbmapR64qYRXGvPc=; b=HPIKtSN1Is/swNaRBOj4kuzWqb9sHL3m/SkejYrhCptU3O08MAoSLUO0YxOfmEfHz2mxFc WUKDtN8ZGrOo5zNVw+pvM5JF54xBequCKhSLSCgf6ML4xa6rNI/rI+gbxRCWDsVArgXVIO MjxbgBwth3Qkzh0gUUQRJDk+/qtaw4w= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-86-ywQtA87cNauowcQ8d2ubjQ-1; Mon, 20 Jun 2022 04:56:06 -0400 X-MC-Unique: ywQtA87cNauowcQ8d2ubjQ-1 Received: by mail-wm1-f70.google.com with SMTP id k5-20020a05600c0b4500b003941ca130f9so3133999wmr.0 for ; Mon, 20 Jun 2022 01:56:06 -0700 (PDT) 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:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=QEyy/6JZbSt5hhSc4lO1WFt1fgnwbmapR64qYRXGvPc=; b=EvBDudwl4oA23Xd+riuMGB8d0w5oKByVg6skxQ1BBnvFSJtW1TcS2wTG+/U82DeuQW 3km3vyiT1LNw0YwipIulTuOgiCbHOq1iko/94U5sy14jkRplfEpgYZ95VXufA7TXFiBu D8S68mZCCSMM/CZoqO4ZtSrZ/NwQB7b1XXcsF02iHBAHc/RYKSQBSHjTR8o3c64Swbg9 IQwr9fB6BKbLCN8G+Qc68hqVSHMva0YkwfSnqJUFA1tR186puEd6FHUFHqZu2TPN1I2b t2744oU3+Gye47M3h0JTq415rK1uqeBcGgVj0iUkyv+qArk42mXc5GP7E1qx2jg/ebB/ /dTg== X-Gm-Message-State: AOAM5324QdQGZz0EQ5HrQBkV919dsVumg3Fl37tlnEZ9MMM2qXNx4FLN gcMv0e1fssYXxpfjM6QBCfFl75THLKJlO/hF6j9Y+ZIgvbMV3sPHnFe9qgJi+wE2nl36qrgJcyC 7fJqFvaLGPp8= X-Received: by 2002:a05:600c:1da4:b0:39c:8ca8:5f1d with SMTP id p36-20020a05600c1da400b0039c8ca85f1dmr33538679wms.138.1655715365268; Mon, 20 Jun 2022 01:56:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzr1ro13LIJcKzfP5ERziX/+M6AnLEwJ6AA+0q3d8eDjW5v/wKfnrKJGnpWgFweL5QvjYawSw== X-Received: by 2002:a05:600c:1da4:b0:39c:8ca8:5f1d with SMTP id p36-20020a05600c1da400b0039c8ca85f1dmr33538645wms.138.1655715365042; Mon, 20 Jun 2022 01:56:05 -0700 (PDT) Received: from ?IPV6:2003:d8:2f04:2500:cdb0:9b78:d423:43f? (p200300d82f042500cdb09b78d423043f.dip0.t-ipconnect.de. [2003:d8:2f04:2500:cdb0:9b78:d423:43f]) by smtp.gmail.com with ESMTPSA id p10-20020a5d48ca000000b002102f2fac37sm12841247wrs.51.2022.06.20.01.56.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Jun 2022 01:56:04 -0700 (PDT) Message-ID: <4be7946c-54f5-80a9-4139-5ae07a89e781@redhat.com> Date: Mon, 20 Jun 2022 10:56:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 2/2] mm: memory_hotplug: make hugetlb_optimize_vmemmap compatible with memmap_on_memory To: Oscar Salvador , Muchun Song Cc: akpm@linux-foundation.org, corbet@lwn.net, mike.kravetz@oracle.com, paulmck@kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, duanxiongchun@bytedance.com, smuchun@gmail.com References: <20220619133851.68184-1-songmuchun@bytedance.com> <20220619133851.68184-3-songmuchun@bytedance.com> <226243a9-b4f5-182e-1a5b-7b8d5c28f3b3@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: 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 ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HPIKtSN1; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf27.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655715368; 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=QEyy/6JZbSt5hhSc4lO1WFt1fgnwbmapR64qYRXGvPc=; b=3fM/C3FUVxpuieqvWNKpnd7J4n6ULJzENPMDJwJxEF8s0ApACUI8kJesvBT6CyNyW6wPYd EYnfFrg0Adey/u83B2OCPAr2ul4bXBpNRTm3Vrb7pcStrx7DH6XFrjG/6huqM/LJbdQbdy HzScMqdyQ3FghxKtOJ78cjS4vGf60w0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655715368; a=rsa-sha256; cv=none; b=PhybFdb4foRMdqeOGawcbD5YHxYLDVEXOhcWBU/ZDa4lASkNQOnSYytGj+Kl2Sw1/lroSq MvG8aRQy6vX71Ca6qULeq/trmTkUpOgqqamttJJGsvyAWSJP+rWr6BRmIggHJg5z5EBvhT 7bQAEZ+1IdbK9vk/66xDayqpKZFFjHY= X-Stat-Signature: 5unk3pgmmtcoe6k38uf6im49c1bokiu6 X-Rspamd-Queue-Id: 496D4400A1 X-Rspam-User: Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HPIKtSN1; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf27.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam10 X-HE-Tag: 1655715368-836649 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.06.22 10:44, Oscar Salvador wrote: > On Mon, Jun 20, 2022 at 04:29:11PM +0800, Muchun Song wrote: >>>> Although it works, I think PageVmemmapSelfHosted() check for the 1st pfn's >>>> vmemmap page is not always reliable. Since we reused PG_owner_priv_1 >>>> as PG_vmemmap_self_hosted, the test is noly reliable for vmemmap page's >>>> vmemmap page. Other non-vmemmap page can be flagged with PG_owner_priv_1. >>>> So this check can be false-positive. Maybe the following code snippet is >>>> the solution. >>> >>> How could that happen for pages used for backing a vmemmap? >>> >> >> It cannot happen for memmap_on_memory case. Howwver, it can happen for other >> cases. E.g. the 1st pfn (of boot memory block) whose vmemmap page may be flagged >> as PG_owner_priv_1 (if PG_swapcache is set). Then, the check is false-positive. > > If this can really happen, which I am not that sure tbh, maybe a way out would be > to just define a new page-type as we did in previous versions of memmap_on_memory. > In that way we would not for flags, but for its type. > > But as I said, I am not entirely sure about the potential fallout of what you mention. We are talking about the memmap of a page, who's page content is the memmap of pages actually exposed to other users (file-backed, anonymous, whatsoever). In other words, while setting PG_swapcache on the memmap of a page exposed to the user is possible, it shouldn't be possible for the memmap of the page "hosting" these memmaps. I know, it's confusing and I keep confusing myself. I tried creating a picture and it doesn't really clarify the situation :D -- Thanks, David / dhildenb