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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4C80CC001B0 for ; Fri, 11 Aug 2023 15:33:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234935AbjHKPd3 (ORCPT ); Fri, 11 Aug 2023 11:33:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230266AbjHKPd2 (ORCPT ); Fri, 11 Aug 2023 11:33:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DA419A5 for ; Fri, 11 Aug 2023 08:32:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691767962; 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=KoDQPpSBax1LLhCBa7z0nPjBBUXe32UXUur+MUFne6M=; b=gVg8FU4wrZz5vKRFIP44UDenWuZNk9k3Nco1hIrmFjpNKCS0+j4gPEjxVigxcZ/svcWnrb aut8JlDKLbAD2DKaF1tbhD+D4cKMnzPFWbd7A209l2xLDb+pN4VLhLdYm0lYLziK6uUA8u iQEYJ5SReeIjbxFVqVLlzHM9Ou+cmY8= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-361-VmDn5umPMamfp_-9CNwhcQ-1; Fri, 11 Aug 2023 11:32:40 -0400 X-MC-Unique: VmDn5umPMamfp_-9CNwhcQ-1 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-3f42bcef2acso12849425e9.2 for ; Fri, 11 Aug 2023 08:32:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691767959; x=1692372759; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KoDQPpSBax1LLhCBa7z0nPjBBUXe32UXUur+MUFne6M=; b=iSMDs6oro2wbxXNzCjQONiry9L4wdyFmoiLZWhLvZgV8ottvoZY/SCQZch/zVM8LWG arzjxdYd3DalEzyEUb4iTpEnPM5UjgFwHwGPup9P8ZpFlgvCkbolD94EJypAeWSJ6jHQ 5N+Ne1l7QM6CbEaTTBZYB48vYnAyYZEPWjYaLHbTP823Zcmbom6sPKwaV+EPX9FZHIGK ZEg75V1A6ZDinPb9LgzGlfk6LsLQDfg35Sx6Q2uLeUY67tl7k+3SIzGUob+Aq1yH3HRM 85sDiIsUR9VozS0P3Vt6za8MMSiECqIlGrNDxQiCI7WUd9fALVdZ36ceScY9i6F4kDpO Mnfw== X-Gm-Message-State: AOJu0YxjNZS5B3Mdofkv1CNz5XALGpHcyX3H/0duamE9GkJtFChIRYzF YAwjp7mchjOS13JwTNsbjdLZlNa7PLjrPQJ3rrN4vG2gaort0L6295uSESnlWUOffofqCVL8Gk8 QWZPvLRdL0nqaGqqMH3d4 X-Received: by 2002:a05:600c:218:b0:3fb:b5dc:dab1 with SMTP id 24-20020a05600c021800b003fbb5dcdab1mr1936913wmi.39.1691767959738; Fri, 11 Aug 2023 08:32:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF0EQWQte4L/bLxPKHwjW9vvzlkJLxja3udxYBIo62C9T+VFPb8pcxrqoMMS3wLa3JyEqeDNQ== X-Received: by 2002:a05:600c:218:b0:3fb:b5dc:dab1 with SMTP id 24-20020a05600c021800b003fbb5dcdab1mr1936889wmi.39.1691767959410; Fri, 11 Aug 2023 08:32:39 -0700 (PDT) Received: from ?IPV6:2003:cb:c71a:3000:973c:c367:3012:8b20? (p200300cbc71a3000973cc36730128b20.dip0.t-ipconnect.de. [2003:cb:c71a:3000:973c:c367:3012:8b20]) by smtp.gmail.com with ESMTPSA id f1-20020a5d6641000000b00314367cf43asm5762156wrw.106.2023.08.11.08.32.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 11 Aug 2023 08:32:38 -0700 (PDT) Message-ID: Date: Fri, 11 Aug 2023 17:32:37 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Content-Language: en-US To: Peter Xu Cc: Matthew Wilcox , Ryan Roberts , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, Andrew Morton , Jonathan Corbet , Mike Kravetz , Hugh Dickins , Yin Fengwei , Yang Shi , Zi Yan References: <20230809083256.699513-1-david@redhat.com> <155bd03e-b75c-4d2d-a89d-a12271ada71b@arm.com> <8222bf8f-6b99-58f4-92cc-44113b151d14@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH mm-unstable v1] mm: add a total mapcount for large folios In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On 11.08.23 17:18, Peter Xu wrote: > On Fri, Aug 11, 2023 at 12:27:13AM +0200, David Hildenbrand wrote: >> On 10.08.23 23:48, Matthew Wilcox wrote: >>> On Thu, Aug 10, 2023 at 04:57:11PM -0400, Peter Xu wrote: >>>> AFAICS if that patch was all correct (while I'm not yet sure..), you can >>>> actually fit your new total mapcount field into page 1 so even avoid the >>>> extra cacheline access. You can have a look: the trick is refcount for >>>> tail page 1 is still seems to be free on 32 bits (if that was your worry >>>> before). Then it'll be very nice if to keep Hugh's counter all in tail 1. >>> >>> No, refcount must be 0 on all tail pages. We rely on this in many places >>> in the MM. >> >> Very right. > > Obviously I could have missed this in the past.. can I ask for an example > explaining why refcount will be referenced before knowing it's a head? I think the issue is, when coming from a PFN walker (or GUP-fast), you might see "oh, this is a folio, let's lookup the head page". And you do that. Then, you try taking a reference on that head page. (see try_get_folio()). But as you didn't hold a reference on the folio yet, it can happily get freed + repurposed in the meantime, so maybe it's not a head page anymore. So if the field would get reused for something else, grabbing a reference would corrupt whatever is now stored in there. -- Cheers, David / dhildenb