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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81B60C38142 for ; Tue, 31 Jan 2023 15:23:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231847AbjAaPXL (ORCPT ); Tue, 31 Jan 2023 10:23:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233242AbjAaPWt (ORCPT ); Tue, 31 Jan 2023 10:22:49 -0500 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F78645BEA for ; Tue, 31 Jan 2023 07:21:26 -0800 (PST) Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-15fe106c7c7so19738676fac.8 for ; Tue, 31 Jan 2023 07:21:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=8uB3Z6qnpneL7fBnCtQQbgmmvnsrVox9LWLijWqPdBg=; b=eu0W+8Bqo5Bcoxbv6tDsvAwivF6vSrDXoaGc/lpNfwiItYZRFNSC+lo5UQR6BbtBLh siZtCrgKLJmaD0HGkrmedkm6U4HGIJdmlc+ySQdutigNcA9ihkjE+Hd0hPuuJE+776KX WgpbxpAgKCpPqT/4tlICCaiclR6v9xbm98pEgWUP2Vmokh0UK9dTNL+ej4xrX/0JPmS4 enME4Y59XTqMGdVC22INOaZUHj6YoFE/xpDHNIvw2qxOPmmg78OxbcxJ8VulCpabagBd MEfYiw7tCt0JILIAKZc2qvUzUGWSblg1vjFtim6FnJKb6iObapLgUFqA7jGNEdwOswUB J9jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8uB3Z6qnpneL7fBnCtQQbgmmvnsrVox9LWLijWqPdBg=; b=fbMQ2mUK0/lfhFYdh/i34IKq1QSER0mHAnyYvXPWWNA15na1nlICUMMbzWeF01AiiV aavr+1S7YWZQ1QBdJ1c4OodfjxJcxjM94EFp29L8SsCkXUW9QsHTy0638U8bHpULWPOC BVfWShZ3mVVmd6WYNHfehfueZDKYcu4pXOGn07rFFbkxsAq8fd4I3P8NeixQgJIDZ+va Wg/BuHDFazFzp+RoAyxWcjMIcAY9P+xDcOaebMKZvJL2b7gKJOT68Hg96rnxrTNoYRm/ 0arz1CNRogLF/iRRujQnVjmn/ybrwDiLMB7cPOxNmiSe7wJMSg1pQdCXu3xaMPwa8A13 STeQ== X-Gm-Message-State: AO0yUKUi+tLXRMhciIrFvxWalr0JZy+ecnoT5E6zRV6VInSxDORDkD6Z wR2ub03meYcV9pwAAeM7SMEeU9y4Fxvk/NGP X-Google-Smtp-Source: AK7set/Ze64lq3+f11Klcyol4ZjsNqkXL5s6RRKkDwsNA2gzWH3GDKWTh18fHiCZTlJOXcECR4zIhA== X-Received: by 2002:a17:902:db05:b0:198:a5d9:f2fd with SMTP id m5-20020a170902db0500b00198a5d9f2fdmr512965plx.6.1675177447799; Tue, 31 Jan 2023 07:04:07 -0800 (PST) Received: from [192.168.1.136] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id j5-20020a170902758500b0019686d286e2sm3901802pll.13.2023.01.31.07.04.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Jan 2023 07:04:07 -0800 (PST) Message-ID: <028c959d-e52a-5d08-6ac6-004ecdb3e549@kernel.dk> Date: Tue, 31 Jan 2023 08:04:06 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [GIT PULL] iov_iter: Improve page extraction (pin or just list) Content-Language: en-US To: David Hildenbrand , David Howells Cc: John Hubbard , Al Viro , Christoph Hellwig , Matthew Wilcox , Jan Kara , Jason Gunthorpe , Logan Gunthorpe , Jeff Layton , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <040ed7a7-3f4d-dab7-5a49-1cd9933c5445@redhat.com> <3351099.1675077249@warthog.procyon.org.uk> <3520518.1675116740@warthog.procyon.org.uk> <3791872.1675172490@warthog.procyon.org.uk> <88d50843-9aa6-7930-433d-9b488857dc14@redhat.com> <7f8f2d0f-4bf2-71aa-c356-c78c6b7fd071@redhat.com> From: Jens Axboe In-Reply-To: <7f8f2d0f-4bf2-71aa-c356-c78c6b7fd071@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/31/23 8:02?AM, David Hildenbrand wrote: > On 31.01.23 15:50, Jens Axboe wrote: >> On 1/31/23 6:48?AM, David Hildenbrand wrote: >>> On 31.01.23 14:41, David Howells wrote: >>>> David Hildenbrand wrote: >>>> >>>>>>> percpu counters maybe - add them up at the point of viewing? >>>>>> They are percpu, see my last email. But for every 108 changes (on >>>>>> my system), they will do two atomic_long_adds(). So not very >>>>>> useful for anything but low frequency modifications. >>>>>> >>>>> >>>>> Can we just treat the whole acquired/released accounting as a debug mechanism >>>>> to detect missing releases and do it only for debug kernels? >>>>> >>>>> >>>>> The pcpu counter is an s8, so we have to flush on a regular basis and cannot >>>>> really defer it any longer ... but I'm curious if it would be of any help to >>>>> only have a single PINNED counter that goes into both directions (inc/dec on >>>>> pin/release), to reduce the flushing. >>>>> >>>>> Of course, once we pin/release more than ~108 pages in one go or we switch >>>>> CPUs frequently it won't be that much of a help ... >>>> >>>> What are the stats actually used for? Is it just debugging, or do we actually >>>> have users for them (control groups spring to mind)? >>> >>> As it's really just "how many pinning events" vs. "how many unpinning >>> events", I assume it's only for debugging. >>> >>> For example, if you pin the same page twice it would not get accounted >>> as "a single page is pinned". >> >> How about something like the below then? I can send it out as a real >> patch, will run a sanity check on it first but would be surprised if >> this doesn't fix it. >> >> >> diff --git a/mm/gup.c b/mm/gup.c >> index f45a3a5be53a..41abb16286ec 100644 >> --- a/mm/gup.c >> +++ b/mm/gup.c >> @@ -168,7 +168,9 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags) >> */ >> smp_mb__after_atomic(); >> +#ifdef CONFIG_DEBUG_VM >> node_stat_mod_folio(folio, NR_FOLL_PIN_ACQUIRED, refs); >> +#endif >> return folio; >> } >> @@ -180,7 +182,9 @@ struct folio *try_grab_folio(struct page *page, int refs, unsigned int flags) >> static void gup_put_folio(struct folio *folio, int refs, unsigned int flags) >> { >> if (flags & FOLL_PIN) { >> +#ifdef CONFIG_DEBUG_VM >> node_stat_mod_folio(folio, NR_FOLL_PIN_RELEASED, refs); >> +#endif >> if (folio_test_large(folio)) >> atomic_sub(refs, folio_pincount_ptr(folio)); >> else >> @@ -236,8 +240,9 @@ int __must_check try_grab_page(struct page *page, unsigned int flags) >> } else { >> folio_ref_add(folio, GUP_PIN_COUNTING_BIAS); >> } >> - >> +#ifdef CONFIG_DEBUG_VM >> node_stat_mod_folio(folio, NR_FOLL_PIN_ACQUIRED, 1); >> +#endif >> } >> return 0; >> > > We might want to hide the counters completely by defining them only > with CONFIG_DEBUG_VM. Are all of them debug aids only? If so, yes we should just have node_stat_* under CONFIG_DEBUG_VM. -- Jens Axboe