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 C88D6C32771 for ; Mon, 26 Sep 2022 07:56:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22B81900015; Mon, 26 Sep 2022 03:56:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DB70900002; Mon, 26 Sep 2022 03:56:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0A34A900015; Mon, 26 Sep 2022 03:56:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id EE096900002 for ; Mon, 26 Sep 2022 03:56:03 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id AF09E4077E for ; Mon, 26 Sep 2022 07:56:03 +0000 (UTC) X-FDA: 79953478206.20.8F57248 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id B0837100003 for ; Mon, 26 Sep 2022 07:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664178962; 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=sNpVlSHHhQ4kCT3FWu+P2c73h8U3yWzRZ1M3sl93EFM=; b=YnaU/tCqV4O21qFtSnzcH0Zn69lLO2HHixdPe/87jhzIEWdLy0deq2yTBZbDjkq0spn6FE byQE+kuwxeNinD4X8N1g5SeIfj0oLLGkUfSy3+Rt7NFedFRRu/smSuzcCG9Gc4aYPJmWx8 MhD5xfJGDUX9jLQyGrQZgCbeJacbjpw= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-55-e35tTaeKM-WjFoyNYa4yVQ-1; Mon, 26 Sep 2022 03:56:00 -0400 X-MC-Unique: e35tTaeKM-WjFoyNYa4yVQ-1 Received: by mail-wm1-f71.google.com with SMTP id e3-20020a05600c218300b003b4e4582006so1552957wme.6 for ; Mon, 26 Sep 2022 00:56:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:subject:organization:from :content-language:references:cc:to:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date; bh=sNpVlSHHhQ4kCT3FWu+P2c73h8U3yWzRZ1M3sl93EFM=; b=urgiI6r6e/o0vcKMckNkth7HF/R8Xn6N5Te5HiOGqvaYTqawrKzL7JsCpZtepmVzrN 8Z3lsWpWxoC0SOQMemb3ddrIrYf1Jc1sLB+BHl5F7qA1sztQ4AFJBoDJU2sFjLWUDOHz HHMgZM/j2P/81qD/67NRxDAu6mifRuZ46fjQrgwr1OLieuCCQgGHozpa2iDugBtg8QuF 0u/w2/+LeP0nWppv1+QRxpwzVyreQRIr2TLRKoUbVTJK0q6WPEIF2tGFh/0/Lt0QCpcz oFeT3Xcq/OU3H0Hb/spkmKCPFPBgbW4VA/OMf87n4viEFFFZkmJVvAWFIl+lkD2+Bpmc zk/g== X-Gm-Message-State: ACrzQf2qXm0Wr8RpqXnniMbuwGnT9KFcMjyyzojzQtSiHHjDVgg2FKN4 5UJ+kXyCxjj0sz0P9xuDMZbhVXQkywkSnfbZz3+R+jtxRxEINoBzZkGPq3cDpLtPmdJ04TCtf/o NDfouUpbCPJs= X-Received: by 2002:adf:dc92:0:b0:22a:415f:8dd7 with SMTP id r18-20020adfdc92000000b0022a415f8dd7mr12030915wrj.708.1664178959737; Mon, 26 Sep 2022 00:55:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6hrjlRKqp9WjazYMTtET1ZpVFwi8jfzKYfo5KkYz8jXi67TzVQ8JFYpB2o2DIVHFudVF88Zw== X-Received: by 2002:adf:dc92:0:b0:22a:415f:8dd7 with SMTP id r18-20020adfdc92000000b0022a415f8dd7mr12030895wrj.708.1664178959442; Mon, 26 Sep 2022 00:55:59 -0700 (PDT) Received: from ?IPV6:2003:cb:c703:4b00:e090:7fa6:b7d6:d4a7? (p200300cbc7034b00e0907fa6b7d6d4a7.dip0.t-ipconnect.de. [2003:cb:c703:4b00:e090:7fa6:b7d6:d4a7]) by smtp.gmail.com with ESMTPSA id e10-20020a5d6d0a000000b002205a5de337sm14967285wrq.102.2022.09.26.00.55.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 26 Sep 2022 00:55:58 -0700 (PDT) Message-ID: Date: Mon, 26 Sep 2022 09:55:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.0 To: Matthew Wilcox , Hyeonggon Yoo <42.hyeyoo@gmail.com> Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Vlastimil Babka , Roman Gushchin , Naoya Horiguchi , Miaohe Lin , Minchan Kim , Mel Gorman , Andrea Arcangeli , Dan Williams , Hugh Dickins , Muchun Song , Andrey Konovalov , Marco Elver References: <20220919125708.276864-1-42.hyeyoo@gmail.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] mm: move PG_slab flag to page_type In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="YnaU/tCq"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1664178963; a=rsa-sha256; cv=none; b=KPyDA5zp+SRgRmkxHUt12EtM5kziXRr47jr2mGSZhH12r4Iw9s8J7U+Rxynly7o/nceGOv sdPYFZf1kxHKILjLDjdE0GnItbxH7RWC6fb+jWjJNpjVUcQO2C1zlfhtmrpHZnDFOejs/l IG8k7RC34lzXsrQQDNxowVN6visF8zA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1664178963; 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=sNpVlSHHhQ4kCT3FWu+P2c73h8U3yWzRZ1M3sl93EFM=; b=4J31YH5QHQoBiRNIFDfWqnHBTwzZMBHOZgajf3lFWlJkKwcru6DckPpq12N5cyeCrOkVO6 7807ROWtN3J0XbhFhybGjYPPrRVShW43HyID/zDmkLRGL9E2/iM9oI/BY5i6/mPm9gAHR+ /63BeRZMPYKytdjyihbncRXF+hYRKbE= X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B0837100003 X-Stat-Signature: hs6wwbui54sgd6proqxp6m7zop4fbb53 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="YnaU/tCq"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com X-HE-Tag: 1664178962-30624 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 25.09.22 01:04, Matthew Wilcox wrote: > On Mon, Sep 19, 2022 at 09:57:08PM +0900, Hyeonggon Yoo wrote: >> For now, only SLAB uses _mapcount field as a number of active objects in >> a slab, and other slab allocators do not use it. As 16 bits are enough >> for that, use remaining 16 bits of _mapcount as page_type even when >> SLAB is used. And then move PG_slab flag to page_type! >> >> Note that page_type is always placed in upper 16 bits of _mapcount to >> avoid confusing normal _mapcount as page_type. As underflow (actually >> I mean, yeah, overflow) is not a concern anymore, use more lower bits >> except bit zero. >> >> Add more folio helpers for PAGE_TYPE_OPS() not to break existing >> slab implementations. >> >> Remove PG_slab check from PAGE_FLAGS_CHECK_AT_FREE. buddy will still >> check if _mapcount is properly set at free. >> >> Exclude PG_slab from hwpoison and show_page_flags() for now. >> >> Note that with this patch, page_mapped() and folio_mapped() always return >> false for slab page. > > This is an interesting approach. It raises some questions. > > First, you say that folio_mapped() returns false for slab pages. That's > only true for order-0 slab pages. For larger pages, > > if (!folio_test_large(folio)) > return atomic_read(&folio->_mapcount) >= 0; > if (atomic_read(folio_mapcount_ptr(folio)) >= 0) > return true; > > so that's going to depend what folio_mapcount_ptr() aliases with. > > Second, this patch changes the behaviour of PageSlab() when applied to > tail pages. Which raises the further question of what PageBuddy(), > PageTable(), PageGuard() and PageIsolated() should do for multi-page > folios, if that is even possible. IIRC, these flags never apply on real compound pages so far. For example, PageBuddy() is only set on the first page of a (budy-aligned) free chunk of memory, and all "remaining" (tail) pages have a refcount of zero and don't have the flag set. There are page tables on some systems (e.g., s390x) that span multiple pages (pmd_alloc_one()). I think the behavior is similar -- no compound page, and only the first page has the flag set. -- Thanks, David / dhildenb