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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B463C43334 for ; Thu, 23 Jun 2022 07:34:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A9F928E0138; Thu, 23 Jun 2022 03:34:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A4F188E0115; Thu, 23 Jun 2022 03:34:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940628E0138; Thu, 23 Jun 2022 03:34:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 858068E0115 for ; Thu, 23 Jun 2022 03:34:17 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 593B721595 for ; Thu, 23 Jun 2022 07:34:17 +0000 (UTC) X-FDA: 79608687354.14.0C1CC24 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by imf31.hostedemail.com (Postfix) with ESMTP id C31802000A for ; Thu, 23 Jun 2022 07:34:16 +0000 (UTC) Received: by mail-pl1-f179.google.com with SMTP id jh14so11124plb.1 for ; Thu, 23 Jun 2022 00:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=p/+VGlu7EcyPo0XUSImIBdbWTMEq+6Oc052Qp24OKmY=; b=g87gZfYG/07FCtRHnX9zajUxqHETsSKV9iQC8Hu3BRmM5QH2sPaqsZtQWZyoQdy0Af 7/5u8dUrmds+D2gmNVlLSTHao0aS9E6oGfMBm8NyCioPs2qeB9C8v5Dz/EJA291lW+0y J+a/FRmu5OIzvUL9mLUyELqNKdZcsSby8+KZW8/zr3yRmHNWfLMZ2ubjRhkW202cCKWZ AlRf+qYiL0WeiHHLj9GFWuM2fUnAX2R8G+vh+Oh8TK8sxZd8crx704NQ3M8MyOoyomZV h1cXsqaK/mhcm/h5cmB0uNPPS5IB9jmfvWQgvfbYdib3iaOOk0YgC+D1XWhy7QOYJFCi OYKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=p/+VGlu7EcyPo0XUSImIBdbWTMEq+6Oc052Qp24OKmY=; b=niO8kEuSzDiF2hh1bt62keUNsZhndzGoYJpRDUBXPgahhbXzwABG46ae7Si1PQWhFM p2/CFY/wjtfO/CmE/DXThfz7vhMS/2ovrzGcVymjAPawKTlUD1J47S5h2wgUAC1h9bU1 5XINbcCKOG+rKnOIucooTzhZqbtzHj6C2bn5kblZ1FNsmiIUy2dBa4y7Fm9PETrc0l5b 1ijFWX6U/tFg/kAQiqN/yhEzUsX6VPV3KN21mYu0soLX5h+Oco406gitAqNisLUvZkVS 7RAq6UAWmbtx+/FyCcDzKBfu7qFu431h6EhwdjVv45zaUHAlflAIOpGCmuTtQdV5ZstV e2Vg== X-Gm-Message-State: AJIora84psRHcNH2lQ5fesyYQm1cCpkfsWsr1Nu5xGj/eeRrP77e1nfy qTaQM42mPgSdR1cFFV37ONvGCA== X-Google-Smtp-Source: AGRyM1tSACTTKI3laHGL+2owy3rlfPwq/RCCBXQ5Ok3ck5BShESEmK+hmWIHJAgEEJyCzFb92o2f7w== X-Received: by 2002:a17:902:d5ce:b0:167:6c02:754c with SMTP id g14-20020a170902d5ce00b001676c02754cmr37379325plh.135.1655969655789; Thu, 23 Jun 2022 00:34:15 -0700 (PDT) Received: from localhost ([139.177.225.231]) by smtp.gmail.com with ESMTPSA id d7-20020a17090a564700b001ec2b1b7d8asm1100466pji.10.2022.06.23.00.34.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jun 2022 00:34:15 -0700 (PDT) Date: Thu, 23 Jun 2022 15:34:11 +0800 From: Muchun Song To: Lv qian Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel@nfschina.com Subject: Re: [PATCH] vmalloc:Merge multiple if conditional sentences Message-ID: References: <20220623064527.4238-1-lvqian@nfschina.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220623064527.4238-1-lvqian@nfschina.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655969657; a=rsa-sha256; cv=none; b=V4I1EiXEaQKLIkuR9glSVXBGr0M2sZbz9gKT+iBA4cY8k8kv/HmoF/XT06AAzHwjPb54Zf Bolu147IUXW+yE8fSf2xB5GVhgSrQt3KCNNb5D/k/NVl2BysigRMy3m9nIZj0DHfDk3NkJ xRuh1fGzfTr/+JPi6ZWyUKWuLMvh0pE= ARC-Authentication-Results: i=1; imf31.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=g87gZfYG; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf31.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655969657; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=p/+VGlu7EcyPo0XUSImIBdbWTMEq+6Oc052Qp24OKmY=; b=X8lguVHz0xzjvgddyhlduqBvpKwHfcoGsgIlROD4/L6pPw3GiGEhH+HbTku/R65vNH7SiR hDYUaDXbaI4G1+uaKTMyGpndWvZ4chzzc9L+cm6zzSPEOfb8KibQDQSvVCWjSfuMezrHN8 crn8e4F7IFAPztEokK1r+h83cAsDe4U= X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: C31802000A Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=g87gZfYG; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf31.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.214.179 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Stat-Signature: ez68cdzdwj3zd7pcwnxtdmnkop71879a X-Rspam-User: X-HE-Tag: 1655969656-793633 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 23, 2022 at 02:45:27PM +0800, Lv qian wrote: > Merge multiple if statements to improve code readability > Hi Lv qian, Why do you think it is more readable? For me, the original one is more readable than yours. Thanks. > Signed-off-by: Lv qian > --- > mm/vmalloc.c | 66 ++++++++++++++-------------------------------------- > 1 file changed, 18 insertions(+), 48 deletions(-) > > diff --git a/mm/vmalloc.c b/mm/vmalloc.c > index effd1ff6a4b4..6902a180f8f7 100644 > --- a/mm/vmalloc.c > +++ b/mm/vmalloc.c > @@ -135,22 +135,12 @@ static int vmap_try_huge_pmd(pmd_t *pmd, unsigned long addr, unsigned long end, > phys_addr_t phys_addr, pgprot_t prot, > unsigned int max_page_shift) > { > - if (max_page_shift < PMD_SHIFT) > - return 0; > - > - if (!arch_vmap_pmd_supported(prot)) > - return 0; > - > - if ((end - addr) != PMD_SIZE) > - return 0; > - > - if (!IS_ALIGNED(addr, PMD_SIZE)) > - return 0; > - > - if (!IS_ALIGNED(phys_addr, PMD_SIZE)) > - return 0; > - > - if (pmd_present(*pmd) && !pmd_free_pte_page(pmd, addr)) > + if (max_page_shift < PMD_SHIFT || > + !arch_vmap_pmd_supported(prot) || > + (end - addr) != PMD_SIZE || > + !IS_ALIGNED(addr, PMD_SIZE) || > + !IS_ALIGNED(phys_addr, PMD_SIZE) || > + (pmd_present(*pmd) && !pmd_free_pte_page(pmd, addr))) > return 0; > > return pmd_set_huge(pmd, phys_addr, prot); > @@ -185,22 +175,12 @@ static int vmap_try_huge_pud(pud_t *pud, unsigned long addr, unsigned long end, > phys_addr_t phys_addr, pgprot_t prot, > unsigned int max_page_shift) > { > - if (max_page_shift < PUD_SHIFT) > - return 0; > - > - if (!arch_vmap_pud_supported(prot)) > - return 0; > - > - if ((end - addr) != PUD_SIZE) > - return 0; > - > - if (!IS_ALIGNED(addr, PUD_SIZE)) > - return 0; > - > - if (!IS_ALIGNED(phys_addr, PUD_SIZE)) > - return 0; > - > - if (pud_present(*pud) && !pud_free_pmd_page(pud, addr)) > + if (max_page_shift < PUD_SHIFT || > + !arch_vmap_pud_supported(prot) || > + (end - addr) != PUD_SIZE || > + !IS_ALIGNED(addr, PUD_SIZE) || > + !IS_ALIGNED(phys_addr, PUD_SIZE) || > + (pud_present(*pud) && !pud_free_pmd_page(pud, addr))) > return 0; > > return pud_set_huge(pud, phys_addr, prot); > @@ -236,22 +216,12 @@ static int vmap_try_huge_p4d(p4d_t *p4d, unsigned long addr, unsigned long end, > phys_addr_t phys_addr, pgprot_t prot, > unsigned int max_page_shift) > { > - if (max_page_shift < P4D_SHIFT) > - return 0; > - > - if (!arch_vmap_p4d_supported(prot)) > - return 0; > - > - if ((end - addr) != P4D_SIZE) > - return 0; > - > - if (!IS_ALIGNED(addr, P4D_SIZE)) > - return 0; > - > - if (!IS_ALIGNED(phys_addr, P4D_SIZE)) > - return 0; > - > - if (p4d_present(*p4d) && !p4d_free_pud_page(p4d, addr)) > + if (max_page_shift < P4D_SHIFT || > + !arch_vmap_p4d_supported(prot) || > + (end - addr) != P4D_SIZE || > + !IS_ALIGNED(addr, P4D_SIZE) || > + !IS_ALIGNED(phys_addr, P4D_SIZE) || > + (p4d_present(*p4d) && !p4d_free_pud_page(p4d, addr))) > return 0; > > return p4d_set_huge(p4d, phys_addr, prot); > -- > 2.18.2 > >