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 X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB16FC433C1 for ; Wed, 24 Mar 2021 09:12:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 291736157F for ; Wed, 24 Mar 2021 09:12:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 291736157F Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 978076B0283; Wed, 24 Mar 2021 05:12:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 94E0C6B029A; Wed, 24 Mar 2021 05:12:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 815D86B02A7; Wed, 24 Mar 2021 05:12:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0067.hostedemail.com [216.40.44.67]) by kanga.kvack.org (Postfix) with ESMTP id 64F0E6B0283 for ; Wed, 24 Mar 2021 05:12:49 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 2159587EB for ; Wed, 24 Mar 2021 09:12:49 +0000 (UTC) X-FDA: 77954202858.39.FC6DDFE Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf10.hostedemail.com (Postfix) with ESMTP id 33B8C40001FE for ; Wed, 24 Mar 2021 09:12:47 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1616577167; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=LlyCilLi9gnBQ4mdjJqJRMAwnGbNttrFvrQ8qOm68Tk=; b=AET6m3NbPsqJB3GOclSVNFMwSnrJB4ce4z7ng4tRUBK9Awatz2PP7NupRzMmeP/QbMw/AZ dCFh+cnMzx8hL1j6QjYMfT3O3xwgFW8sIljFq5UjpMp/79nVnZWhvrVzHGRPWVQT4Axku+ 4ICeAbKXdv7KNhrW0MPF7YkzwJnJSX0= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 36992AC16; Wed, 24 Mar 2021 09:12:47 +0000 (UTC) Date: Wed, 24 Mar 2021 10:12:46 +0100 From: Michal Hocko To: Arjun Roy Cc: Johannes Weiner , Arjun Roy , Andrew Morton , David Miller , netdev , Linux Kernel Mailing List , Cgroups , Linux MM , Shakeel Butt , Eric Dumazet , Soheil Hassas Yeganeh , Jakub Kicinski , Yang Shi , Roman Gushchin Subject: Re: [mm, net-next v2] mm: net: memcg accounting for TCP rx zerocopy Message-ID: References: <20210316041645.144249-1-arjunroy.kdev@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: w4r1srdnorn5qhs444g4i9pbxrdpd88x X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 33B8C40001FE Received-SPF: none (suse.com>: No applicable sender policy available) receiver=imf10; identity=mailfrom; envelope-from=""; helo=mx2.suse.de; client-ip=195.135.220.15 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616577167-204513 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 Tue 23-03-21 11:47:54, Arjun Roy wrote: > On Tue, Mar 23, 2021 at 7:34 AM Michal Hocko wrote: > > > > On Wed 17-03-21 18:12:55, Johannes Weiner wrote: > > [...] > > > Here is an idea of how it could work: > > > > > > struct page already has > > > > > > struct { /* page_pool used by netstack */ > > > /** > > > * @dma_addr: might require a 64-bit value even on > > > * 32-bit architectures. > > > */ > > > dma_addr_t dma_addr; > > > }; > > > > > > and as you can see from its union neighbors, there is quite a bit more > > > room to store private data necessary for the page pool. > > > > > > When a page's refcount hits zero and it's a networking page, we can > > > feed it back to the page pool instead of the page allocator. > > > > > > From a first look, we should be able to use the PG_owner_priv_1 page > > > flag for network pages (see how this flag is overloaded, we can add a > > > PG_network alias). With this, we can identify the page in __put_page() > > > and __release_page(). These functions are already aware of different > > > types of pages and do their respective cleanup handling. We can > > > similarly make network a first-class citizen and hand pages back to > > > the network allocator from in there. > > > > For compound pages we have a concept of destructors. Maybe we can extend > > that for order-0 pages as well. The struct page is heavily packed and > > compound_dtor shares the storage without other metadata > > int pages; /* 16 4 */ > > unsigned char compound_dtor; /* 16 1 */ > > atomic_t hpage_pinned_refcount; /* 16 4 */ > > pgtable_t pmd_huge_pte; /* 16 8 */ > > void * zone_device_data; /* 16 8 */ > > > > But none of those should really require to be valid when a page is freed > > unless I am missing something. It would really require to check their > > users whether they can leave the state behind. But if we can establish a > > contract that compound_dtor can be always valid when a page is freed > > this would be really a nice and useful abstraction because you wouldn't > > have to care about the specific type of page. > > > > But maybe I am just overlooking the real complexity there. > > -- > > For now probably the easiest way is to have network pages be first > class with a specific flag as previously discussed and have concrete > handling for it, rather than trying to establish the contract across > page types. If you are going to claim a page flag then it would be much better to have it more generic. Flags are really scarce and if all you care about is PageHasDestructor() and provide one via page->dtor then the similar mechanism can be reused by somebody else. Or does anything prevent that? -- Michal Hocko SUSE Labs