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 1451AC433F5 for ; Tue, 12 Oct 2021 07:25:08 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B2870610A3 for ; Tue, 12 Oct 2021 07:25:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B2870610A3 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 F19066B006C; Tue, 12 Oct 2021 03:25:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EC8F3900002; Tue, 12 Oct 2021 03:25:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D90296B0073; Tue, 12 Oct 2021 03:25:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0001.hostedemail.com [216.40.44.1]) by kanga.kvack.org (Postfix) with ESMTP id C7C7D6B006C for ; Tue, 12 Oct 2021 03:25:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 849491802E6DF for ; Tue, 12 Oct 2021 07:25:06 +0000 (UTC) X-FDA: 78686949012.01.F611BA5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 2FB0FD008C76 for ; Tue, 12 Oct 2021 07:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634023505; 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=QCaCvkButWX/9cpKIUZ5gR/122oJghoG1CwqhsqHSVg=; b=Cx6B6tOj2a5jUIjbIfiv1H9q/uDWjgPIkXtaKqdOmmo7XxSrTjj9ZZUZ3Hze3R1VuyNayO YfI4P0m60Ox4mkEwC92xIEmreWLl3SeebTnlD2yxx1p16QEOyjCIhAvU8nwr3711f4NpAb fW7L0YZQGs2YuWCsORprVnkNR5NIvFc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-6XsGVBQLPo6CeyERbhbclQ-1; Tue, 12 Oct 2021 03:25:04 -0400 X-MC-Unique: 6XsGVBQLPo6CeyERbhbclQ-1 Received: by mail-wr1-f72.google.com with SMTP id c2-20020adfa302000000b0015e4260febdso14982726wrb.20 for ; Tue, 12 Oct 2021 00:25:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:references:from:organization:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=QCaCvkButWX/9cpKIUZ5gR/122oJghoG1CwqhsqHSVg=; b=sLK3QEv6+ZdDK3uVWlpGqSTpyjqyCl0AAOQrd7lFd8Il2KNZrzJm2c0NNLI+vYXw8K 0G9o+JquSDQFe7vYNxTYB4L5T4XgU/0jchexdTr095PYQNHM1g+y8RqzLcijqtLu/ELC TyRhsSSFy+IdiPwjYo8UgyEvXhfdMfLiEEixcrfSUK0Xz0ptxBcVJvwj7wI0ytxbbD2H MXO5NrCsy3dDsiqq1wZWeODJwjXW4gyuNAsejg3+dpn3p/Kb2zwyTa7lVi40DceC21jM H5CYKO5IOQ3Fw+oG4FsQdSItXbsHcvvJ3S+4TSsAWK72hVOofgvohbSZMHvF6yXt7Euu EjPw== X-Gm-Message-State: AOAM532nkCO+Ier8hygr1IuMUUbIztIhWSZHLjLPah8d9UTyhvKavUTq etJpHj1rUPCtbBzR3J1DCdwC3RznKk+DFN0rCXL+wP8AUdqVEm+SkPa8KgV37rKMZrhc3t8omp8 2W+NWIxvhzRMx+lZSddaeWwf2ByYXcGNGBatBCT+bi9mt5K4USPIfIBK/hts= X-Received: by 2002:a05:6000:184b:: with SMTP id c11mr20648095wri.29.1634023503457; Tue, 12 Oct 2021 00:25:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywe1AcrkQRbtT84ZewNKZoyq0mb9hJRJz9uSysl5x2KW4WamM4dCifWQHjZyd3JYoDstSo0g== X-Received: by 2002:a05:6000:184b:: with SMTP id c11mr20648068wri.29.1634023503186; Tue, 12 Oct 2021 00:25:03 -0700 (PDT) Received: from [192.168.3.132] (p5b0c6a12.dip0.t-ipconnect.de. [91.12.106.18]) by smtp.gmail.com with ESMTPSA id e16sm8085521wrw.17.2021.10.12.00.25.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Oct 2021 00:25:02 -0700 (PDT) To: Matthew Wilcox Cc: linux-mm@kvack.org References: <20211004134650.4031813-1-willy@infradead.org> <20211004134650.4031813-4-willy@infradead.org> <02a055cd-19d6-6e1d-59bb-e9e5f9f1da5b@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 03/62] mm: Split slab into its own type Message-ID: <425cd66f-2040-4278-6149-69a329a82f79@redhat.com> Date: Tue, 12 Oct 2021 09:25:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Cx6B6tOj; spf=none (imf20.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2FB0FD008C76 X-Stat-Signature: sdaz6puac9ujxqc9yrxftqpy3f1oha1y X-HE-Tag: 1634023506-160833 Content-Transfer-Encoding: quoted-printable 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 05.10.21 20:48, Matthew Wilcox wrote: > On Tue, Oct 05, 2021 at 06:10:24PM +0200, David Hildenbrand wrote: >> My 2 cents just from reading the first 3 mails: >> >> I'm not particularly happy about the "/* Reuses the bits in struct pag= e */" >> part of thingy here, essentially really having to pay attention what >> whenever we change something in "struct page" to not mess up all the o= ther >> special types we have. And I wasn't particularly happy scanning patch = #1 and >> #2 for the same reason. Can't we avoid that? >=20 > I've tried to mitigate that with the compile-time assertions. They're > actually a bit stronger than what we have now. Sorry for the late reply. Okay, that's at least something :) >=20 >> What I can see is that we want (and must right now for generic >> infrastructure) keep some members of the the struct page" (e.g., flags= , >> _refcount) at the very same place, because generic infrastructure reli= es on >> them. >> >> Maybe that has already been discussed somewhere deep down in folio mai= l >> threads, but I would have expected that we keep struct-page generic in= side >> struct-page and only have inside "struct slab" what's special for "str= uct >> slab". >> >> I would have thought that we want something like this (but absolutely = not >> this): >> >> struct page_header { >> unsigned long flags; >> } >> >> struct page_footer { >> atomic_t _refcount; >> #ifdef CONFIG_MEMCG >> unsigned long memcg_data; >> #endif >> } >> >> struct page { >> struct page_header header; >> uint8_t reserved[$DO_THE_MATH] >> struct page_footer footer; >> }; >=20 > The problem with this definition is the number of places which refer > to page->flags and must now be churned to page->header.flags. > _refcount is rather better encapsulated, and I'm not entirely sure > how much we'd have to do for memcg_data. Maybe that was what you meant > by "this but absolutely not this"? I don't quite understand what that > was supposed to mean. Exactly what you mentioned above (changing all callers) is what I didn't=20 want :) I was thinking of a way to have these "fixed fields" be defined only=20 once, and ideally, perform any access to these fields via the "struct=20 page" instead of via the "struct slab". Like, when wanting to set a page flag with a slab, access them ((struct page *)slab)->flags instead of using slab->flags. Essentially not duplicating these fields=20 and accessing them via the "refined" page types, but only putting a=20 "reserved" placeholder in. That would mean that we wouldn't need patch=20 #1 and #2, because we wouldn't be passing around pgflags (using whatever=20 fancy type we will decide on), all such accesses would continue going=20 via the "struct page" -- because that's where these common fields=20 actually reside in right now at places we cannot simply change --=20 because common infrastructure (PFN walkers, ...) heavily relyies on the=20 flags, the refcount and even the mapcount (page types) being set=20 accordingly. >=20 >> struct slab { >> ... >> }; >> >> struct slab_page { >> struct page_header header; >> struct slab; >> struct page_footer footer; >> }; >> >> Instead of providing helpers for struct slab_page, simply cast to stru= ct >> page and replace the structs in struct slab_page by simple placeholder= s with >> the same size. >> >> That would to me look like a nice cleanup itself, ignoring all the oth= er >> parallel discussions that are going on. But I imagine the problem is m= ore >> involved, and a simple header/footer might not be sufficient. >=20 > Yes, exactly, the problems are more involved. The location/contents of > page->mapping are special, the contents of bit zero of the second word > are special (determines compound_head or not) and slub particularly > relies on the 128-bit alignment of the { freelist, counters } pair. >=20 > The ultimate destination (and I think Kent/Johannes/I all agree > on this) is to dynamically allocate struct slab. At _that_ point, > we can actually drop _refcount from struct slab and even change how > struct slab is defined based on CONFIG_SLUB / CONFIG_SLOB / CONFIG_SLAB= . I'm also sold on the idea of simplifying "struct page" (even when not=20 shrinking it!) by moving out these "struct slab" parts that dictate the=20 "struct page" layout heavily. > I think we'll still need ->flags to be the first element of struct slab= , > but bit 0 of the second word stops being special, we won't need to care > about where page->mapping aliases, and the 128-bit alignment becomes > solely the concern of the slub allocator instead of affecting everyone > who uses struct page. Yes, that sounds good to me. --=20 Thanks, David / dhildenb