Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6979961rwb; Mon, 12 Dec 2022 08:36:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf7T9XvPSztX++gcg8xIUkLgyNyZw10xtzPfWhILWxcok2nAj3tZ+gp7J/ALsAqb/up2S83/ X-Received: by 2002:a17:902:768b:b0:186:865c:ea17 with SMTP id m11-20020a170902768b00b00186865cea17mr16712564pll.38.1670862977651; Mon, 12 Dec 2022 08:36:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670862977; cv=none; d=google.com; s=arc-20160816; b=sRVRQFu2QE2yvJlEdXMy/hVmDlDWhlePAIRXraQaZKlgvsDmay97UhsUv+Q6k6mahm 95u3uVtPst9qoZzIBlOY0fhkp92HKetsYr+f7vLvIZgUpdEopNqFG7BD8ItsERqz0JPT Jnhaek2qGGeNNHNnPQumk8uDin3FTBPJ2e7HazcEJ1Zxr73cBuC5T7/qk8EMMx1pbf38 DOUZWX4iYSO6qy8X4zfkOVNlg8TTCIqdr3u/evOqBocA2uq53p5vs0xO5yNERqzoA1ak cG8TzTQnMbeaxtWs4e4ps16ILj+AWo3LexO8TGTlHwAsq1ZCwaXnR0m1uOqExquhdVO3 sxww== 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=qTolJC9fUfjb3pLzxYSP1dBl1foIc1xzVjzAvOAu5Oo=; b=aXoZRdc65tVcuaGcALwv3b0Txmzj4WFj303RvR9LTSFDnwW2KcbfgI26r/yWaqLMl6 rdd25SdZZuvIsYtZFgicqU0508l9lsH0pCOasFdbPL/UmwocNOS1lrLnib2cEMZeTzUC D1Yx2KDae0HfViNqbAA3xwmY266x2FPF+56/21WVPN40z/kRRDDZzqa7EaqPOepB9IVF gRmrswyFD8yytM/FQZHKaB+gmRp0U59cFEIJnOXDdT+4D2Zg6x903RzyDwaoeoCeY09N r03xvT56Svqu6MQyNFy+XQ9BGU+o0WcHYz6QOcXFJjVRVMG5krfsNU3yX5h6C7sTrStd jsMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=JSx+G5IE; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a170902e74d00b00186aad06b52si9956151plf.290.2022.12.12.08.36.07; Mon, 12 Dec 2022 08:36:17 -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=@infradead.org header.s=casper.20170209 header.b=JSx+G5IE; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232720AbiLLQZD (ORCPT + 76 others); Mon, 12 Dec 2022 11:25:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231715AbiLLQZA (ORCPT ); Mon, 12 Dec 2022 11:25:00 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 20D9FB48B for ; Mon, 12 Dec 2022 08:24:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=qTolJC9fUfjb3pLzxYSP1dBl1foIc1xzVjzAvOAu5Oo=; b=JSx+G5IEaMaHeabCqfyh2vEwKw ftLHw1tCdPxx6RJ4qQV6TEF4qayiik5lnF6rEEpqn0a/P1pZxhwY9vMfbQeulKM8uMX+t18wQiHGM Up77a2zYD1uXpqPunkKfpAVVpJXwDnq78QDQ499ll72LH3e2vdCVkwnhC4+hoYFNY0Ep5hKZ+oulA kN9DvK3uZPuMpmw5NjY8RMAS/COPov7o3mXCsgOViWg3YfF8Ke5dk3QPw6z8ucouVALOv2YfmGibo ULC4uNegvbFzfozPTb4cbtJkFYrRuNDESPg6wkqfOOS6t6/2pS40uDU2O/YJmjyxFixbl2UscW9+f SOH0T6fw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1p4lbu-00BDpp-Sf; Mon, 12 Dec 2022 16:24:58 +0000 Date: Mon, 12 Dec 2022 16:24:58 +0000 From: Matthew Wilcox To: Nhat Pham Cc: Al Viro , akpm@linux-foundation.org, hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, bfoster@redhat.com, kernel-team@meta.com Subject: Re: [PATCH v2 3/4] cachestat: implement cachestat syscall Message-ID: References: <20221205175140.1543229-1-nphamcs@gmail.com> <20221205175140.1543229-4-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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 08:23:31AM -0800, Nhat Pham wrote: > > It would be easier to read if you inverted the condition here. > > Oh I think I tried > > if (!f.file) > return -EBADF; > > here, but there are some mixing-code-with-decl warnings. > If I recall correctly, the problem is with this line: > > XA_STATE(xas, &mapping->i_pages, first_index); > > which is expanded into a declaration: > > #define XA_STATE(name, array, index) \ > struct xa_state name = __XA_STATE(array, index, 0, 0) > > It requires a valid mapping though, which is > obtained from f.file: > > struct address_space *mapping = f.file->f_mapping; > > so it cannot be moved above the if(!f.file) check either... Perhaps you're trying to do too much in a single function?