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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 6DA73C433DB for ; Thu, 4 Feb 2021 12:37:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 25BC664F53 for ; Thu, 4 Feb 2021 12:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236102AbhBDMhK (ORCPT ); Thu, 4 Feb 2021 07:37:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236036AbhBDMhH (ORCPT ); Thu, 4 Feb 2021 07:37:07 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 520B6C061573 for ; Thu, 4 Feb 2021 04:36:27 -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=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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!