Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp233676pxf; Wed, 24 Mar 2021 03:59:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/018b1lm2TMtJy3Eq4R20aCOD0dG1CQKx6xQ3ts8C8Sn8Vn7nPmyyUrQ1nNMsqqJxE7e+ X-Received: by 2002:a17:906:2b46:: with SMTP id b6mr2929586ejg.521.1616583560150; Wed, 24 Mar 2021 03:59:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616583560; cv=none; d=google.com; s=arc-20160816; b=vtgQDN4arblkHMzUffDgW1PO1LMJsx0VGShiucc8DXtevdUph2BiBMaxwiAF4oArYO 8LRTob9u3TkOe+D6/LjK6Dd3qhy/2OGKxBPDH8T65XDXi5gwcyEDb/VyQjl+hgAHdkm9 XYpCdC4+pq+tElIDhQPJLkKt+xcAGTk5UIPtKOTjQroOIMvSwi2iZmIOIJmTW6RWdfQ3 Oj81oK7J5rul5VScsmWcCucxNKuSpmYnx7YCxP5IACNALLpn06OVDqbZAgGzCNuX/h4n 6mva7nKYQovxeEfluoVV5QDyogsl+Pl/IiwBrXtrziWs9P5GHwCwe/FGV1ah1y0aXzzW CQfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LlyCilLi9gnBQ4mdjJqJRMAwnGbNttrFvrQ8qOm68Tk=; b=LAcuQa7mBb5Vvm9dCf9YP7y36Ov1o6EN5fitpVjQXJOddFqKWF0PpuoUw1KuUlC/NI HXUXfaxNmZUMf4j46RbLdsVr/lqAmf+ciu/qrf62RXB6Rzebf7f6/8W5Tts8dVW8WL/Z NfMnpwKuE0TcmbtpLLAzOGHiQcEG/nQV5K4n/2kVTdCS/4TKKeVWFqtBxiNRlc7FnyZQ gHY73d6V6EXbF+slvUS0NQdbkLagfPmVXt8kNg1lvCeK17nGzPhAnL5fPYw8qdz9RWNz RENnqUQL290sLu2i+PQCZ8iVQCMVp6Ngm+kLdcfTx88CcPWpdh1HeVydCPpOKzcnWgZ3 mNlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=AET6m3Nb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l23si1535343ejb.573.2021.03.24.03.58.57; Wed, 24 Mar 2021 03:59:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=AET6m3Nb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234575AbhCXJNI (ORCPT + 99 others); Wed, 24 Mar 2021 05:13:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:33394 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234491AbhCXJMs (ORCPT ); Wed, 24 Mar 2021 05:12:48 -0400 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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