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=-8.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 BBF5EC432C2 for ; Tue, 24 Sep 2019 15:16:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6EE8A20665 for ; Tue, 24 Sep 2019 15:16:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=shutemov-name.20150623.gappssmtp.com header.i=@shutemov-name.20150623.gappssmtp.com header.b="RwAr5QCF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6EE8A20665 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1A47C6B000A; Tue, 24 Sep 2019 11:16:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 17CD16B0269; Tue, 24 Sep 2019 11:16:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 092436B026A; Tue, 24 Sep 2019 11:16:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id D956E6B000A for ; Tue, 24 Sep 2019 11:16:55 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 8359F8243778 for ; Tue, 24 Sep 2019 15:16:55 +0000 (UTC) X-FDA: 75970166790.05.curve60_1f438df5b1810 X-HE-Tag: curve60_1f438df5b1810 X-Filterd-Recvd-Size: 6631 Received: from mail-ed1-f67.google.com (mail-ed1-f67.google.com [209.85.208.67]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Sep 2019 15:16:54 +0000 (UTC) Received: by mail-ed1-f67.google.com with SMTP id r9so2182639edl.10 for ; Tue, 24 Sep 2019 08:16:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bijUKP9uPxouhGcd1htXTfvDLPDNF2aF59LJ8pKbGVw=; b=RwAr5QCFNuqjuBy75MwEOPtlduLb8CpVBSMDCwFghHcPVcvL8pujx/O6FmjBSO6Cld 4Vir9A55d3m/02fGYrTT30yNRDejCIS/GX2MaI/Hpgr1yuhXnIzJ9lbWA6YmpMu+Ssh6 +3UrM4y3uwpc/Fuh52w3WOAxql427aic7/Su4igir/ot9V2Irz/HP6m45geigtNyqPvE UTUOcIAD8yVeu5+SMEVeQ+GBWjreDSi3yaZjMLUQ4AWDYlECZQu7HwZ47IRXsRStyuul I3kQbSPl6lQLuK4p2AQu1M7ygHgLC/do+Rw0BALPBr+L3KziJDWvIBq+gVHOOZhfZswB cAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bijUKP9uPxouhGcd1htXTfvDLPDNF2aF59LJ8pKbGVw=; b=nhz1ARwjCePgzxXJpJfw95GEuUuPIhdD+D/0+rN24N0BsyPSaqKotZDA7AGHPNbYpe CZCgREXc7sSq8uwlya9dBBB+JCwkHTVRw8Pnyw8zGfgbjJG67uGxdtZ6NgiJk9X6V1LK 1zRGyfnbRMLYcRDa5BqmDqOHaJWLeoVQRXGCfkvEvRMOqz5pXMh5AWneXghKL71kIo6I bkxQv3zS5rB+D1qBmF7VXFNxWVx6wT6CRL7QfU1fS9TsC23zbIra179BHPon5JqFq0NW b43YuvhJ8klCetinitYW5zYOVEXh4I03Uu45fK5yc3r10AJ4M+ji8l1mDqVCm0c8hhcL daiA== X-Gm-Message-State: APjAAAXS8xrtPlihJVDO7cALjzrJhUP1cQg0KEwG+RF6Zd2hka/JqDNp fThxLdXsKtR4/6FiEHJWf0ZM9Q== X-Google-Smtp-Source: APXvYqzQcMhs5X+f3hlVnseFIl/P8nstkjyohZ+qybVIWqBtACSnnwdlq/O6aEoTRP2ZHbeRHAJBxw== X-Received: by 2002:a17:906:c4b:: with SMTP id t11mr2963153ejf.131.1569338213558; Tue, 24 Sep 2019 08:16:53 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id y25sm239403eju.39.2019.09.24.08.16.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Sep 2019 08:16:53 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id AA0201022AB; Tue, 24 Sep 2019 18:16:52 +0300 (+03) Date: Tue, 24 Sep 2019 18:16:52 +0300 From: "Kirill A. Shutemov" To: Vlastimil Babka Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org, "Kirill A. Shutemov" , Michal Hocko , Mel Gorman , Matthew Wilcox Subject: Re: [PATCH v2 2/4] mm, page_owner: record page owner for each subpage Message-ID: <20190924151652.bjtjgj7brflrgcuv@box> References: <20190820131828.22684-1-vbabka@suse.cz> <20190820131828.22684-3-vbabka@suse.cz> <20190924113135.2ekb7bmil3rxge6w@box> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 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, Sep 24, 2019 at 05:10:59PM +0200, Vlastimil Babka wrote: > On 9/24/19 1:31 PM, Kirill A. Shutemov wrote: > > On Tue, Aug 20, 2019 at 03:18:26PM +0200, Vlastimil Babka wrote: > >> Currently, page owner info is only recorded for the first page of a high-order > >> allocation, and copied to tail pages in the event of a split page. With the > >> plan to keep previous owner info after freeing the page, it would be benefical > >> to record page owner for each subpage upon allocation. This increases the > >> overhead for high orders, but that should be acceptable for a debugging option. > >> > >> The order stored for each subpage is the order of the whole allocation. This > >> makes it possible to calculate the "head" pfn and to recognize "tail" pages > >> (quoted because not all high-order allocations are compound pages with true > >> head and tail pages). When reading the page_owner debugfs file, keep skipping > >> the "tail" pages so that stats gathered by existing scripts don't get inflated. > >> > >> Signed-off-by: Vlastimil Babka > >> --- > >> mm/page_owner.c | 40 ++++++++++++++++++++++++++++------------ > >> 1 file changed, 28 insertions(+), 12 deletions(-) > >> > >> diff --git a/mm/page_owner.c b/mm/page_owner.c > >> index addcbb2ae4e4..813fcb70547b 100644 > >> --- a/mm/page_owner.c > >> +++ b/mm/page_owner.c > >> @@ -154,18 +154,23 @@ static noinline depot_stack_handle_t save_stack(gfp_t flags) > >> return handle; > >> } > >> > >> -static inline void __set_page_owner_handle(struct page_ext *page_ext, > >> - depot_stack_handle_t handle, unsigned int order, gfp_t gfp_mask) > >> +static inline void __set_page_owner_handle(struct page *page, > >> + struct page_ext *page_ext, depot_stack_handle_t handle, > >> + unsigned int order, gfp_t gfp_mask) > >> { > >> struct page_owner *page_owner; > >> + int i; > >> > >> - page_owner = get_page_owner(page_ext); > >> - page_owner->handle = handle; > >> - page_owner->order = order; > >> - page_owner->gfp_mask = gfp_mask; > >> - page_owner->last_migrate_reason = -1; > >> + for (i = 0; i < (1 << order); i++) { > >> + page_owner = get_page_owner(page_ext); > >> + page_owner->handle = handle; > >> + page_owner->order = order; > >> + page_owner->gfp_mask = gfp_mask; > >> + page_owner->last_migrate_reason = -1; > >> + __set_bit(PAGE_EXT_OWNER, &page_ext->flags); > >> > >> - __set_bit(PAGE_EXT_OWNER, &page_ext->flags); > >> + page_ext = lookup_page_ext(page + i); > > > > Isn't it off-by-one? You are calculating page_ext for the next page, > > right? > > You're right, thanks! > > > And cant we just do page_ext++ here instead? > > Unfortunately no, as that implies sizeof(page_ext), which only declares > unsigned long flags; and the rest is runtime-determined. > Perhaps I could add a wrapper named e.g. page_ext_next() that would use > get_entry_size() internally and hide the necessary casts to void * and back? Yeah, it looks less costly than calling lookup_page_ext() on each iteration. And looks like it can be inlined if we make 'extra_mem' visible (under different name) outside page_ext.c. -- Kirill A. Shutemov