Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp7979395rwl; Thu, 23 Mar 2023 11:00:28 -0700 (PDT) X-Google-Smtp-Source: AK7set/E5c+OnsbWiT+AaTTPKnHgobM/h8meoM4g0VnmDB+is6Q3sLKrLsaJNdRtR/6vR63QaAbr X-Received: by 2002:a17:906:a41a:b0:8f6:52c:afa0 with SMTP id l26-20020a170906a41a00b008f6052cafa0mr13412755ejz.23.1679594428671; Thu, 23 Mar 2023 11:00:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679594428; cv=none; d=google.com; s=arc-20160816; b=XYUSAYGlgH9Ff2dHImGKvQQwi74wE/1zfujeaKIdznp0eCHlo6Tv56k6/dyjoL9Cqp felxF8CCHAIjtfgemzkYqiaItXC7XVKhUnb/xP3jJI7PiLQVdvRSRUZurnB6LzwKmvnk 6YBGUs+CWfHVJ1j+sAQ52D7+nt7jZZFlmLWpOFDrQMHblOro/CdFdShRFqkqMl4e9Lxs 1svxDixvaYn9xZK/jrgy8BYgJMcYe6XLZ65ud/sCbe5RjIhhr76QBr7SKXIqORsJY3Rk 0d4yLsWJIrFGfzmOMYCzHpES98Q4um788MgV9CzGKf1Sqq4rmLYk0FRfBaDcz8OsWnDz fv9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=62jyzyEgX+HzAgLQ6e6LF2w+MDlBZYNdXnQaSgmglN4=; b=OPQvB4HTB5MiocBv1VvzKUEoJcD3O8RoWgrgB1i+ZhKwZQGBrwOoZ++MNTx8roSMAv PHkdbuGzywXZL/2B2MWeLDknQJLNL0EbXLBoDAT2UhR/ZmwsRKWBbrGYDMR4QNszpCt5 A+2o6AlvEfVRy1UWpPJgHvQBUO+jLgK95QmcBddrX+TrrOmuZcOqbSs+fNMyVjvQNFJT La10jVpM4Q9d1xu5nBmxm70NkxiRykKSwWs8hlxpuD0krJqm3X4q6VkQgOsqymCRorjI N/dWF/QnCizouw7PYIM9TOCwlnmJ8oeHxGxDuvKkAtcQ5fX3hvTUBZAN/o4PgMTafhii TnNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="X/3A440z"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l22-20020a170906a41600b009301cec4c31si11249705ejz.994.2023.03.23.11.00.04; Thu, 23 Mar 2023 11:00:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="X/3A440z"; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230487AbjCWR6F (ORCPT + 99 others); Thu, 23 Mar 2023 13:58:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbjCWR6D (ORCPT ); Thu, 23 Mar 2023 13:58:03 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC1120A3C for ; Thu, 23 Mar 2023 10:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679594238; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=62jyzyEgX+HzAgLQ6e6LF2w+MDlBZYNdXnQaSgmglN4=; b=X/3A440zIK4dNdhMzoe1xmGn2Zy/Azo3ZpS8FCl9ByHHHnocMEUUXK8/2KkezQ7O/scoJl +W73sx4FO5ftycb4uEMzuOsnVQtJppX2Y/ZcOnVFh2TV56HGhRk/H4d082thEjzozTWKxr LElb295ttaWz9kZPQXh0ky2K9jFvu2s= Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-567-Sj7kSSYkNSGrf1Wsau72vg-1; Thu, 23 Mar 2023 13:57:17 -0400 X-MC-Unique: Sj7kSSYkNSGrf1Wsau72vg-1 Received: by mail-pj1-f70.google.com with SMTP id nu18-20020a17090b1b1200b0023fbe01dc06so1258566pjb.8 for ; Thu, 23 Mar 2023 10:57:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679594236; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=62jyzyEgX+HzAgLQ6e6LF2w+MDlBZYNdXnQaSgmglN4=; b=CbyouUldQLZohKrm9kl/txyFBH5gtPCsIml84i5DY+Azj/ukTljA/47VTO0Voggaxo QFZMAWXmTInnz37xIyr33NsT1cImmcIakrUmgoXrzaLk1jaHm3JDswEyq//AfHdzLAiL 3jGvNrK8aQXgTpK/LIkRE3UcfB4wVmRThN4rAuzMTvj5AMweN6BHhaGirHG9/kE1zgQ8 6k5A/eE34L5CxCzQV83fDmQiuKAuAqQ/KFBZ9FhzMuBPpjbqxwKNlJHkEGUyisUYCHAn Ksz/64MB5/ls2b5MvdPjtCqPtXC+voSeno1Vm/c5cPKf2HCO5hjPRErrJEgPVyNvyQea 9WBQ== X-Gm-Message-State: AO0yUKVhK+QFh5jhhN8NScuf2d0ueAb40b6aT8U7zUpm5kiFdDXHZDeV z93xaQLQmFnIpeTtkfyDvGD/ITZMMnNlsd40sqSt80xyYwjLHnQ2ywM5ivgUSoe1nO1M6/pIplA R/4TI3caizBepR1h8t4I0Jbq5xH+VImC3l4g5 X-Received: by 2002:a65:63ce:0:b0:50a:c176:385b with SMTP id n14-20020a6563ce000000b0050ac176385bmr2256905pgv.0.1679594235889; Thu, 23 Mar 2023 10:57:15 -0700 (PDT) X-Received: by 2002:a65:63ce:0:b0:50a:c176:385b with SMTP id n14-20020a6563ce000000b0050ac176385bmr2256903pgv.0.1679594235559; Thu, 23 Mar 2023 10:57:15 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Wysochanski Date: Thu, 23 Mar 2023 13:56:38 -0400 Message-ID: Subject: Re: /proc/PID/io/read_bytes accounting regression? To: David Howells Cc: Daire Byrne , linux-nfs , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Fri, Feb 17, 2023 at 10:59=E2=80=AFAM Matthew Wilcox wrote: > > On Fri, Feb 17, 2023 at 10:47:01AM -0500, David Wysochanski wrote: > > On Fri, Feb 17, 2023 at 9:36 AM Matthew Wilcox wr= ote: > > > > > > On Fri, Feb 17, 2023 at 09:08:27AM -0500, David Wysochanski wrote: > > > > On Fri, Feb 17, 2023 at 6:56 AM Daire Byrne wrote: > > > > > On newer kernels, it looks like the task io accounting is not > > > > > incrementing the read_bytes when reading from a NFS mount? This w= as > > > > > definitely working on v5.16 downwards, but has not been working s= ince > > > > > v5.18 up to v6.2 (I haven't tested v5.17 yet). > > > > > > > > In v5.16 we had this call to task_io_account_read(PAGE_SIZE); on li= ne 109 > > > > of read_cache_pages(); > > > > > > > > But there's no call to task_io_account_read() anymore in the new > > > > readahead code paths that I could tell, > > > > but maybe I'm missing something. > > > > > > > > Willy, > > > > Does each caller of readahead_page() now need to call > > > > task_io_account_read() or should we add that into > > > > readahead_page() or maybe inside read_pages()? > > > > > > I think the best way is to mimic what the block layer does as closely= as > > > possible. Unless we can pull it out of the block layer & all > > > filesystems and put it in the VFS (which we can't; the VFS doesn't > > > know which blocks are recorded by the filesystem as holes and will no= t > > > result in I/O). > > > > > Caller, ok. I see, that makes sense. > > Looks like cifs has a call to task_io_account_read() after data has bee= n > > received. Also netfs has a call as well at the bottom of > > netfs_rreq_unlock_folios(). > > Both seems to be _after_ data has been received, but I'm not sure that'= s > > correct. > > It's probably correct, just different from the block layer. I don't > have any special insight here, just an inclination to be as similar > as possible. > > > > The block layer does it as part of the BIO submission path (and also > > > counts PGPGIN and PGPGOUT, which no network filesystems seem to do?) > > > You're more familiar with the NFS code than I am, so you probably > > > have a better idea than __nfs_pageio_add_request(). > > > > > Hmm, yes does the block layer's accounting take into account actual > > bytes read or just submitted? Maybe I need to look at this closer > > but at first glance it looks like these numbers may sometimes be > > incremented when actual data is received and others are incremented > > when the submission happens. > > > > As to the right location in NFS, the function you mention isn't a bad > > idea, but maybe not the right location. Looking in nfs_file_direct_rea= d() > > we have the accounting at IO submission time, appears to be the > > same as the block layer. Also since my NFS netfs conversion patches > > are still outstanding, I'll have to somehow take the netfs call into ac= count > > if fscache is enabled. So the right place is looking like somewhere > > in nfs_read_folio() and nfs_readahead(). > > Yes, we don't want to double-count either fscache or direct I/O. > I'm Maybe Dave as opinions about where we should be accounting it -- > I'm not sure that netfs is the right place to do it. Maybe it should > be in each network filesystem instead of in netfs? > David - can you comment on whether you agree the call to task_io_account_read() inside netfs_rreq_unlock_folios() is wrong? I think based on the discussion here, the definition in the kernel docs, and the fact we have to record against the proper PID, the accounting should be done in the caller of the netfs interfaces not inside netfs unlock path. It looks like afs may rely on netfs IO accounting but can it be moved?