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 CE3D6C433F5 for ; Thu, 3 Mar 2022 19:14:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235870AbiCCTPL (ORCPT ); Thu, 3 Mar 2022 14:15:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235859AbiCCTPG (ORCPT ); Thu, 3 Mar 2022 14:15:06 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D77515B99F; Thu, 3 Mar 2022 11:14:17 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id kt27so12871492ejb.0; Thu, 03 Mar 2022 11:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MOPMhEIV3XBqtSikTY4+v1vOWvKvVs3Rd1CFsa26faY=; b=fR/x2GeKfTrG9900nwOrBgV5oSRy4W2QKTw4oL1vHBDVFBa38opaw7zkQ3fLU9TsLn ntWBKdfXvF11tgQtBZbED1QqD8NWDqW/TOsb7DrwQvr7xRz6vtmalgZ/qAUUM3D+CDkS N1fkOb8+Cymr61nGyH5KcFvnbZwcUu3vi3GeSOjkB6mo/uQ7Om7MZl+EReG1/3C5LSkM q3p7IDRiDte3vM4YjYfE8cNWe/XT65G0xlcAhzB4Dhre25tA5tRd0rMngqg+m0a5Vzw2 t14HeSI0vcMIi8fZJHEMwEiN8FGnfbB/zqkhELp53IB4njYD2h3vskak5Xu9MvO70XbU cWRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MOPMhEIV3XBqtSikTY4+v1vOWvKvVs3Rd1CFsa26faY=; b=HvJ9PekAhE1fqD7dCbJ0yomfEu15BdLU6uo4wnKMlVeHyVpbf7K9HKgDv6LzDB3FIs x6oG9re648myuSv4nWGKSljwYvzWiiQeA0QiUPi5GVhBRkN0wUGhoSMgxjelpCvXB8X1 vfYhmeruHzdG4Uu32sifVUrY9XkcAHSdqf4j3UrIzkmeHR39321FGXwr36ldebBOwYCt SxG7MDyuesw/hnah89o/R5So487zOOpmIlvkhWhfbEthjBO3E/jdEQfvulZfeMAOR4Sc UQ/lKMIHCPpISzM/30bhnyk8P7HcY6aqaKLvyzfNSbAzK3ueJIk8ZHcSpyKxqekTK0Cn rDbQ== X-Gm-Message-State: AOAM531wycsq3szgGy8oZ0Xz/MBQrYebDkJFljNybLKCUSDGVoixuzDI Qr6FekGWsoVZkW6gj6jAbqsKSSv02uG7o6XmL0E= X-Google-Smtp-Source: ABdhPJyQRfkxu/g6AA1xO+7oThr+yX8gEw6C/+hhhtZO3+lPLKAOC5cvmmD1Mk0guaV/AzzmFu6KIscF0rWwnMGoeGQ= X-Received: by 2002:a17:906:e28a:b0:6d6:e2e9:d39d with SMTP id gg10-20020a170906e28a00b006d6e2e9d39dmr12350886ejb.2.1646334855632; Thu, 03 Mar 2022 11:14:15 -0800 (PST) MIME-Version: 1.0 References: <202203020034.2Ii9kTrs-lkp@intel.com> <6c8b9d6b-fc31-11d6-c5d4-c18b3854b4e9@huawei.com> In-Reply-To: <6c8b9d6b-fc31-11d6-c5d4-c18b3854b4e9@huawei.com> From: Yang Shi Date: Thu, 3 Mar 2022 11:14:03 -0800 Message-ID: Subject: Re: [PATCH 4/8] mm: thp: only regular file could be THP eligible To: Miaohe Lin Cc: Dan Carpenter , kernel test robot , kbuild-all@lists.01.org, Linux MM , Linux FS-devel Mailing List , linux-ext4@vger.kernel.org, linux-xfs@vger.kernel.org, Linux Kernel Mailing List , kbuild@lists.01.org, Vlastimil Babka , "Kirill A. Shutemov" , Song Liu , Rik van Riel , Matthew Wilcox , Zi Yan , Andrew Morton , "Theodore Ts'o" , Andreas Dilger , darrick.wong@oracle.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 3, 2022 at 3:48 AM Miaohe Lin wrote: > > On 2022/3/3 19:43, Dan Carpenter wrote: > > Hi Yang, > > > > url: https://github.com/0day-ci/linux/commits/Yang-Shi/Make-khugepaged-collapse-readonly-FS-THP-more-consistent/20220301-075903 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev > > config: arm64-randconfig-m031-20220227 (https://download.01.org/0day-ci/archive/20220302/202203020034.2Ii9kTrs-lkp@intel.com/config) > > compiler: aarch64-linux-gcc (GCC) 11.2.0 > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kernel test robot > > Reported-by: Dan Carpenter > > > > smatch warnings: > > include/linux/huge_mm.h:179 file_thp_enabled() warn: variable dereferenced before check 'vma->vm_file' (see line 177) > > mm/khugepaged.c:468 hugepage_vma_check() error: we previously assumed 'vma->vm_file' could be null (see line 455) > > include/linux/huge_mm.h:179 file_thp_enabled() warn: variable dereferenced before check 'vma->vm_file' (see line 177) > > > > vim +179 include/linux/huge_mm.h > > > > 2224ed1155c07b Yang Shi 2022-02-28 175 static inline bool file_thp_enabled(struct vm_area_struct *vma) > > 2224ed1155c07b Yang Shi 2022-02-28 176 { > > 2224ed1155c07b Yang Shi 2022-02-28 @177 struct inode *inode = vma->vm_file->f_inode; > > ^^^^^^^^^^^^^^ > > Dereference. > > > > 2224ed1155c07b Yang Shi 2022-02-28 178 > > 2224ed1155c07b Yang Shi 2022-02-28 @179 return (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) && vma->vm_file && > > ^^^^^^^^^^^^ > > Checked too late. > > Yep. We should check vma->vm_file first before we access vma->vm_file->f_inode. Ah, yes, thanks for the report and the suggestion. > > Thanks. > > > > > 2224ed1155c07b Yang Shi 2022-02-28 180 (vma->vm_flags & VM_EXEC) && > > 2224ed1155c07b Yang Shi 2022-02-28 181 !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode); > > 2224ed1155c07b Yang Shi 2022-02-28 182 } > > > > --- > > 0-DAY CI Kernel Test Service, Intel Corporation > > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org > > > > . > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============5506336948760778028==" MIME-Version: 1.0 From: Yang Shi To: kbuild-all@lists.01.org Subject: Re: [PATCH 4/8] mm: thp: only regular file could be THP eligible Date: Thu, 03 Mar 2022 11:14:03 -0800 Message-ID: In-Reply-To: <6c8b9d6b-fc31-11d6-c5d4-c18b3854b4e9@huawei.com> List-Id: --===============5506336948760778028== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable On Thu, Mar 3, 2022 at 3:48 AM Miaohe Lin wrote: > > On 2022/3/3 19:43, Dan Carpenter wrote: > > Hi Yang, > > > > url: https://github.com/0day-ci/linux/commits/Yang-Shi/Make-khugepag= ed-collapse-readonly-FS-THP-more-consistent/20220301-075903 > > base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git = dev > > config: arm64-randconfig-m031-20220227 (https://download.01.org/0day-ci= /archive/20220302/202203020034.2Ii9kTrs-lkp(a)intel.com/config) > > compiler: aarch64-linux-gcc (GCC) 11.2.0 > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kernel test robot > > Reported-by: Dan Carpenter > > > > smatch warnings: > > include/linux/huge_mm.h:179 file_thp_enabled() warn: variable dereferen= ced before check 'vma->vm_file' (see line 177) > > mm/khugepaged.c:468 hugepage_vma_check() error: we previously assumed '= vma->vm_file' could be null (see line 455) > > include/linux/huge_mm.h:179 file_thp_enabled() warn: variable dereferen= ced before check 'vma->vm_file' (see line 177) > > > > vim +179 include/linux/huge_mm.h > > > > 2224ed1155c07b Yang Shi 2022-02-28 175 static inline bool file_th= p_enabled(struct vm_area_struct *vma) > > 2224ed1155c07b Yang Shi 2022-02-28 176 { > > 2224ed1155c07b Yang Shi 2022-02-28 @177 struct inode *inode =3D v= ma->vm_file->f_inode; > > ^= ^^^^^^^^^^^^^ > > Dereference. > > > > 2224ed1155c07b Yang Shi 2022-02-28 178 > > 2224ed1155c07b Yang Shi 2022-02-28 @179 return (IS_ENABLED(CONFIG= _READ_ONLY_THP_FOR_FS)) && vma->vm_file && > > = ^^^^^^^^^^^^ > > Checked too late. > > Yep. We should check vma->vm_file first before we access vma->vm_file->f_= inode. Ah, yes, thanks for the report and the suggestion. > > Thanks. > > > > > 2224ed1155c07b Yang Shi 2022-02-28 180 (vma->vm_flags & V= M_EXEC) && > > 2224ed1155c07b Yang Shi 2022-02-28 181 !inode_is_open_for= _write(inode) && S_ISREG(inode->i_mode); > > 2224ed1155c07b Yang Shi 2022-02-28 182 } > > > > --- > > 0-DAY CI Kernel Test Service, Intel Corporation > > https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org > > > > . > > > --===============5506336948760778028==--