Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4300853pxf; Tue, 23 Mar 2021 07:36:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9d00KNWKVbc/LBoYTKHvcIyYQEtoejSbrBgvxcRPgyeXmFXatFXHyCsPOJqWIiOmnHUDW X-Received: by 2002:a17:906:2c0c:: with SMTP id e12mr5267254ejh.408.1616510210383; Tue, 23 Mar 2021 07:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616510210; cv=none; d=google.com; s=arc-20160816; b=Cn6YY+e4W/82Oq9DaTr/V29ih9a5KRF/Y/QKuKN1NO8/jfW3K32GFZyQttgEXwaUZY HQyt1Cthee+hZQu+cF3iW2UxuMUXJ2Gl38LaH+y2U0F6P5ktiVn/WOm4yDHhZtInJZ4X KD7oIaand89ew4/SqHhzBRDI8XMGJfGJXzPTuVoKPRymRHWgpl/lPLTfhgoDefOOrvCX VnzhuKo+kwyLLoiokRSNVlP3Uq9CTqkKKWi6/Pa494ftpbbqtiYhsGU1pUsMtXosS92H lEMoRDOFrt2iZZSk0TVBaifEcPm+7R+uLlfUxR2AdYzOmmpnYETvpNfQNRo2n27uM10m K7fA== 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=U6AYmAE3axZU7Y0KUT99DSxo5RPJIf5s+7Dy88I1Wdg=; b=YvIc64xSTbC4TFk+kWBL7AoUX+aOgAkVrHIxkSiPWhq+PmmnjhFMYpYoRjmgNSAHtJ NS5YmsOOkyx8Lpf01wXeFRHNnNBI08CVRCgD8OG+sC8cjwoFRjS73iixQfVRMHFWCVSY rC5X3e91FuzcktCtquGQ/yC6kEuYDAwF+Eb122cbdeXCFxuTzmdRt8a60H6ypsbiUs3W +OYG9QBzQhAZ4eCGOB7lnv2n2gDRvKP1ZWHWiGWe6BQgq490IGhlTObmBWJKBrVX0rsb pOhCVGPs6XaPJCuU0A5M6mSoOH/qedmIf+cKn3eZ3vT/op5NoLg8a1HM/IwJLuFYy+W3 z49Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=vUoROcuh; 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 pk25si13886819ejb.402.2021.03.23.07.36.27; Tue, 23 Mar 2021 07:36:50 -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=vUoROcuh; 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 S232353AbhCWOen (ORCPT + 99 others); Tue, 23 Mar 2021 10:34:43 -0400 Received: from mx2.suse.de ([195.135.220.15]:53558 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231830AbhCWOeX (ORCPT ); Tue, 23 Mar 2021 10:34:23 -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=1616510061; 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=U6AYmAE3axZU7Y0KUT99DSxo5RPJIf5s+7Dy88I1Wdg=; b=vUoROcuhUJ8TVeKb7PORfNjQR1dmz/iSaXTllYT7iJQTfH0qjQLXrU+7jK2uLB7GR2hoFG m+8V9mml9J2vpquf2lzURMMvfwwKcmQCcNKfWXvUV0odfTIdwUgQSOhBILiplh1EFx4ucw ppXcwU9GX3xYTiamctYDF0mhMZc1NBQ= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 1ECE0ACBF; Tue, 23 Mar 2021 14:34:21 +0000 (UTC) Date: Tue, 23 Mar 2021 15:34:20 +0100 From: Michal Hocko To: Johannes Weiner Cc: Arjun Roy , 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 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. -- Michal Hocko SUSE Labs