Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7059405rwb; Mon, 12 Dec 2022 09:31:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf6qF0UiPcOjocetwELBEz9amDCRQPy3hqNcdiRa9vAv3XDZHNvh2FX7NolLy4XUGPBEvv4F X-Received: by 2002:a17:906:2314:b0:7c0:d522:decb with SMTP id l20-20020a170906231400b007c0d522decbmr12572600eja.76.1670866292119; Mon, 12 Dec 2022 09:31:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670866292; cv=none; d=google.com; s=arc-20160816; b=nmus4uMgV/C6HWiimACwlDBWuoBUtyVgJ65rM1xU4oYe6eMsSo128rdCCMzmwDMVdt tiYw1+JAnUifHM7qlWeQs/S7C7flA27NCtvDA90ZhwecT1m0O5QNxqJU8KmtC1dZyK/r GDT99jakCXp28m+RYLhDwC6r0iyG23QWgwUX127iGzlaNcYMg6+X8t7IjO85PS328Qcd C0kT+libjoqCL30iSPW25MtvpIwAA1TnYDUfUsw0o0M9I4i/g9HtIwgBFEVeJ2fsh6yA 5lPURDgZzy1fYnnBAnXfBvLTYRbnoi7GIwujoUlZTLPqcV6rV/ASMKiKWs+gLC/VrM2o Qd6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=zdKYitirjFUvJOqH75WY9wqcicdY0ZKchesIKslPTDk=; b=fY2WqoBMjmXAs7IdNTNyULur0ui+HnDK30wi1D4UxsJSkf5zM3lWJ6cY0EF1W7spiG l5Iml/UxpWm8TFihgvD4EjdQbfaBxH0zzy3nx+U4fU7RrYYOsRh4pmFSQQ2VQcWFU/tk yN/nFQyA+eAY6eQhbg7lNkWObNkOYCcXGHsx696nBiIlieHKbKswuol2GD91/wRKTJfP mtkVhicSguTcPsL0davdfxUf6H3NFgT+6bNGd9jeuG4ICqLBxndZxj37C9vAtEo5oDBX pzH8Y6pRysMYdaiS/GuLw1K/A/eIHoPVa0Z6QmUqqNK9iXg6qTFZdYmadakT4l5ozlpP gQVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Nm57cZd0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k11-20020a1709062a4b00b007ba16fcfefdsi235923eje.936.2022.12.12.09.31.14; Mon, 12 Dec 2022 09:31:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@gmail.com header.s=20210112 header.b=Nm57cZd0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232131AbiLLQvM (ORCPT + 74 others); Mon, 12 Dec 2022 11:51:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229515AbiLLQvK (ORCPT ); Mon, 12 Dec 2022 11:51:10 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D514388A for ; Mon, 12 Dec 2022 08:51:08 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id q7so12732201wrr.8 for ; Mon, 12 Dec 2022 08:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=zdKYitirjFUvJOqH75WY9wqcicdY0ZKchesIKslPTDk=; b=Nm57cZd02W0zL2/5xwuBi9IHyI8TrElP/I6CSCoax110itKNY5B71nnPey5vGNTI5E D2WdKEFM4MXdvvoW72zhyrH4oGnRjPEVP029fpVn1R2bq8dCKubrCJyrRMNF7ahTXN7D VYYXk7b9s3WSrbyYR3hoqmyiBZbMNPi4k7YxxU2YQyC6wVkgMR2KUDbwWNrPWATQFqWl H24NgXTNsqnVIgXipJqBnFCGgxTy0FMP+Je2mJuJzh3HiftFMYb5tg4jPCekwnfF42rG SiLvMEyWoum5oY6jIUdXdGOalPXT97WuEoqpn/JLfKg4RY4sVTl3A5JfoKvaPoJRrfqX Mbzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=zdKYitirjFUvJOqH75WY9wqcicdY0ZKchesIKslPTDk=; b=7bO4j9oPTf+BTRMeVqMhaibb2VUc49tGgzYGhdLDCy9d+rXhNcbnUShGwZSIgi7ubp 8MuwIOCmR/qfqQCo6yuwAfatYpAuQPJwjuhdHbpml4b4wRXsmZ8nJVISKitr2R2WVEvr 7Rdhm6joO3QvkVZ9JfX9U+q6g/JcVV82FR7TddGan1IXGL+GJYrIWEJYQ99k16IZNMKB 8JvwPukOcrTUC3XZSMsc6/ElvnEhtgk8eu5CpVFSEuDYZDKF2sMFi18Od+HkkYBjfR6W 1McFlsQAxio4ZFGRWvLCd6ncAgo+b3tkF4QPkRblxW4SurBJ/Y71sINI8PLJ+oERC5mD d2qA== X-Gm-Message-State: ANoB5plJgfV1+RD2bspJp7cuwqSh8H8gmbhjv2MjOjDmaIF52CrRCW0b aCHmx3jggS88npVcFBkqiHwf919BNpCnVRI6Ii0= X-Received: by 2002:adf:df81:0:b0:242:6553:668e with SMTP id z1-20020adfdf81000000b002426553668emr10674273wrl.131.1670863867123; Mon, 12 Dec 2022 08:51:07 -0800 (PST) MIME-Version: 1.0 References: <20221205175140.1543229-1-nphamcs@gmail.com> <20221205175140.1543229-4-nphamcs@gmail.com> In-Reply-To: From: Nhat Pham Date: Mon, 12 Dec 2022 08:50:55 -0800 Message-ID: Subject: Re: [PATCH v2 3/4] cachestat: implement cachestat syscall To: Brian Foster Cc: Al Viro , akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, willy@infradead.org, kernel-team@meta.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-kernel@vger.kernel.org On Mon, Dec 12, 2022 at 5:22 AM Brian Foster wrote: > > On Sat, Dec 10, 2022 at 11:51:32PM +0000, Al Viro wrote: > > On Mon, Dec 05, 2022 at 09:51:39AM -0800, Nhat Pham wrote: > > > > > + if (!access_ok(cstat, sizeof(struct cachestat))) > > > + return -EFAULT; > > > > What for? You are using copy_to_user() later, right? > > > > > + f = fdget(fd); > > > + if (f.file) { > > > > It would be easier to read if you inverted the condition here. > > > > Seconded.. I mentioned the same the last time I looked at this. On > looking again, perhaps it might even make sense to create a > filemap_cachestat() to split up the syscall bits from the associated map > walking bits..? That subsequently raises the question of whether a new > .c file is really necessary.. > > Brian > Personally, I think it's better to add a new .c file for the new syscall. But I'm impartial with respect to the refactoring otherwise. I'll just give it a shot and see if it looks cleaner. (BTW - I just realized this is the v2 thread. I have sent out a v3 - feel free to take a look at that as well! These comments are still valid for the new version though).