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 X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F86CC433E0 for ; Thu, 4 Feb 2021 12:36:28 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F4E064DE9 for ; Thu, 4 Feb 2021 12:36:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F4E064DE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F091F6B0005; Thu, 4 Feb 2021 07:36:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E920B6B006E; Thu, 4 Feb 2021 07:36:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5BBA6B0070; Thu, 4 Feb 2021 07:36:26 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0068.hostedemail.com [216.40.44.68]) by kanga.kvack.org (Postfix) with ESMTP id BB99B6B0005 for ; Thu, 4 Feb 2021 07:36:26 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7D0331EE6 for ; Thu, 4 Feb 2021 12:36:26 +0000 (UTC) X-FDA: 77780533572.23.waste57_1f08eff275dc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 5554637604 for ; Thu, 4 Feb 2021 12:36:26 +0000 (UTC) X-HE-Tag: waste57_1f08eff275dc X-Filterd-Recvd-Size: 2682 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 12:36:25 +0000 (UTC) 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=lX7iwFJIwyhAiv1j9hQe0jAQ98de3k2S3cgvATMKuT8=; b=Po+H8FMhRGxCfokUVBTpJeWLFa muPLstpAuu/qRn3Q4IBm4oqMpWj5en7Dob4RLTnSP6s1lmU1anfErXTv78BudVgfcePZj1LyTBZw5 mOb6QXaLMdyhIc42Gk0K8IWqVKKTYWSDtqNCaWxuKlB99aUI9+TWYijLccUK28pbVm8hxSl6m0+t+ enbPTKjjBwR8RCWkpv6g3lgsRAhMrlajjZRv+ovqrL0eNJh6toFHv/IGqOOAcvCfe4F0bPBDOANKx 2H7VoIBgBEjJZmRV40YAVzB06vHuNmd1q3XS1XSyIqlOHZn/1EbSLwmeTNcGZsZLuhI2bmpA4HZPs dNlkpfJw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1l7drh-000rij-Fj; Thu, 04 Feb 2021 12:36:09 +0000 Date: Thu, 4 Feb 2021 12:36:05 +0000 From: Matthew Wilcox To: Miaohe Lin Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/pgtable-generic.c: optimize the VM_BUG_ON condition in pmdp_huge_clear_flush() Message-ID: <20210204123605.GD308988@casper.infradead.org> References: <20210203084137.25522-1-linmiaohe@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210203084137.25522-1-linmiaohe@huawei.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Feb 03, 2021 at 03:41:37AM -0500, Miaohe Lin wrote: > The developer will have trouble figuring out why the BUG actually triggered > when there is a complex expression in the VM_BUG_ON. Because we can only > identify the condition triggered BUG via line number provided by VM_BUG_ON. > Optimize this by spliting such a complex expression into two simple > conditions. > pmd_t pmd; > VM_BUG_ON(address & ~HPAGE_PMD_MASK); > - VM_BUG_ON(!pmd_present(*pmdp) || (!pmd_trans_huge(*pmdp) && > - !pmd_devmap(*pmdp))); > + VM_BUG_ON(!pmd_present(*pmdp)); > + /* Below assumes pmd_present() is true */ > + VM_BUG_ON(!pmd_trans_huge(*pmdp) && !pmd_devmap(*pmdp)); This is not a complex condition. We're in the huge PMD handling case and we're looking at a PMD which either isn't present or isn't huge. It might be useful to print out the PMD in such a case, but splitting this into the two cases of pmd-not-present and pmd-isn't-huge isn't particularly useful. I think you know that, or you wouldn't feel the need to put in a comment explaining it!