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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54C28C433EF for ; Wed, 27 Oct 2021 12:14:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D11DF60E54 for ; Wed, 27 Oct 2021 12:14:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D11DF60E54 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 4A574940008; Wed, 27 Oct 2021 08:14:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 42DA7940007; Wed, 27 Oct 2021 08:14:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CE6B940008; Wed, 27 Oct 2021 08:14:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0244.hostedemail.com [216.40.44.244]) by kanga.kvack.org (Postfix) with ESMTP id 1A010940007 for ; Wed, 27 Oct 2021 08:14:47 -0400 (EDT) Received: from smtpin36.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C19B48249980 for ; Wed, 27 Oct 2021 12:14:46 +0000 (UTC) X-FDA: 78742110972.36.352F3A1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 493E610000B1 for ; Wed, 27 Oct 2021 12:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1635336884; 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=7Aj6XmcK91/v06jY+9Tuc19QLsPx+Gg+f+2vNQvHr9s=; b=SN020HPp9oyg3RLTL/zEXP/PHbS3k+PeK1D7UOmNSOZXklWK6Dkne9igflybdapAw+WkTi RCFOsznT+mA8D0DzO7QnsJgqeVz+27fAO/Cy/9FvLgRhfb6+Bm/FqwP79lq68K0lG1FiMx nASD8vLzp39b8/WxiGM/d9f0bL8ecjM= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-8OeuGDgJNmKCQ0hhelQm9Q-1; Wed, 27 Oct 2021 08:14:40 -0400 X-MC-Unique: 8OeuGDgJNmKCQ0hhelQm9Q-1 Received: by mail-wm1-f70.google.com with SMTP id b81-20020a1c8054000000b0032c9d428b7fso1184158wmd.3 for ; Wed, 27 Oct 2021 05:14:40 -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=7Aj6XmcK91/v06jY+9Tuc19QLsPx+Gg+f+2vNQvHr9s=; b=KVX0Jwrn9/IMqwvx9d2VtNaPTcrKPMY7GI3Eb4MiJq+wsY/VJ5wkadnxIgBOZP1Y8Y TPBQ3g3YsO7FHzdlBa3gAWa7c12pcvJSzrnHnhJ9V1HoHxKDDieeFNFYanJ0cLXXFppr s7tDxDN+zO2YCSQocjfbchV0WZsHziWxujG9WjlIlyTtgdaojyvayPPxEI/D1IEhqWgN Z6gjFNdPrmVbZw6gSF1GqkADXGUE2O7DNWS0HjN0EWsV43qdjP0iWxKMjN5Qy6t1SwHp pFyBlR81J3kCI5HqsoErgh8sbLYZYBH3W/mZ4nNam2yGRlDPlt6wVFEMXYsKBSnpt4GV bSmg== X-Gm-Message-State: AOAM533o6P43q7fAYFpXOtCem2APzAEjReJP5WNEYlkbYI+pSF+bg/Aa LVsVXYk05TjRRaBsK+MXWUzz4TJSeKs+j79MdOdn0supEYAq5i9WKx6G3gCIgajbsHPYI9lqrm+ dKIkpnyp/yv8= X-Received: by 2002:a1c:a557:: with SMTP id o84mr1360260wme.184.1635336879488; Wed, 27 Oct 2021 05:14:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTSbkOPNiEsYEd9Pg9UqC+DPB/5om8yARPe0YG6osgIAUJO8DF7OOghu13vbF5sermbZZw3A== X-Received: by 2002:a1c:a557:: with SMTP id o84mr1360233wme.184.1635336879212; Wed, 27 Oct 2021 05:14:39 -0700 (PDT) Received: from [192.168.3.132] (p4ff23d76.dip0.t-ipconnect.de. [79.242.61.118]) by smtp.gmail.com with ESMTPSA id t8sm4034936wrx.47.2021.10.27.05.14.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Oct 2021 05:14:38 -0700 (PDT) Message-ID: <5a55874d-80b9-b622-ec98-1bfdf3b251bf@redhat.com> Date: Wed, 27 Oct 2021 14:14:38 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: Dynamically allocated memory descriptors To: Kent Overstreet , Matthew Wilcox Cc: linux-mm@kvack.org, Johannes Weiner References: 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 X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 493E610000B1 X-Stat-Signature: 1o4en9satg6m5kqhfwaozh5jdbwxxgmb Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=SN020HPp; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf07.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-HE-Tag: 1635336886-288528 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 26.10.21 19:22, Kent Overstreet wrote: > On Mon, Oct 25, 2021 at 08:55:21PM +0100, Matthew Wilcox wrote: >> Kent asked: >>> I ran into a major roadblock when I tried converting buddy allocator >>> freelists to radix trees: freeing a page may require allocating a new >>> page for the radix tree freelist, which is fine normally - we're freeing >>> a page after all - but not if it's highmem. So right now I'm not sure >>> if getting struct page down to two words is even possible. Oh well. >> >> I don't think I can answer this without explaining the whole design >> I have in mind, so here goes ... this is far more complicated than >> I would like it to be, but I think it *works*. > > So you've got two separately allocated structs per compound page - struct buddy, > for allocator/freelist state, and struct folio or slab or whatever, for > allocatee state. This lets you get struct page - our 4k page tax - down to a > single pointer. > > But the shenanigans required for separately allocating struct buddy make me want > to go back to my proposal :) > > The difference between your proposal and mine is that in mine, we don't > separately allocate struct buddy, instead we only shrink struct page down to two > words/pointers, not one. We can get the state for a free page down to two words > if we replace the doubly linked freelists with a dequeue implemented as a radix > tree: the second word in struct page will be a pointer to allocatee state for > allocated pages, but for free pages it will be an index onto the freelist. > > As you also noted, splitting page->flags up between allocator state and > allocatee state (i.e. moving some of it to the folio) means we'll be able to fit > compound/buddy order in page->flags; that becomes the allocator state word in my > model. > > The issue I ran into was where we have to allocate new pages for the freelist > radix tree: normally there's no issue here because we can just consume the page > we're trying to free. But if the page is highmem - oof. ZONE_MOVABLE and MIGRATE_CMA is similarly problematic, no? -- Thanks, David / dhildenb