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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89B70C4332F for ; Mon, 12 Dec 2022 16:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232723AbiLLQZD (ORCPT ); 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: 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?