Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp522781ima; Wed, 6 Feb 2019 04:12:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IaGeNBKcYVAOExwLP041jNioh7xoYlirw9oIaKkkfzmCOAdmudMH+UKNJsrfOUPOkS7WbE3 X-Received: by 2002:a62:2044:: with SMTP id g65mr10105602pfg.127.1549455134799; Wed, 06 Feb 2019 04:12:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549455134; cv=none; d=google.com; s=arc-20160816; b=jBuk9hMDogk7F50VjstiKbus/51JTTZD0zuXZlGtOs8Y6Sy6DndySM0LzNEms3sOjk Z0QpeASp4G9xuyKFNIUBBXw8nlhVZZElvgkMXP5M+ztJiAtU7UmqAJ7VCcNeL9A+D7cp 3Vw7QlocPbcu/IkAWksNfDBLrjaGseSqXhmk+P5yzSEACPDLeftcMWPJBmMM98Dl5kbK xkzuK7MSanzCO/Nt9mrq4fKAotoOz3tsQEbxcNPduPh7QmCEW7i4vazb6XyRGLJlD7ps v3olPNVT5tfwlcaI5ybvwDzINYKoNC18O+w+fgivG8hMYh7I7vBpJb2EXGvMRY2Y+ioZ ff3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=ejrM/R9eeplk9uFxz2XWIrvDnzfU1UrbJSgB2j/O9l0=; b=og/bOpSI2GUWa6Gg68B9c61tgxrF6E1JzP1kepvyxm/4N5UB11antJBH93A2Alk2Cn f8Ll1PhvOmu2JqYg6Aok1R8KqAssVo/lvBc4IPZzsIFuIEThUlBN9/EzDHJ8Q4hh0zp/ BTJz7irUf/0P8BjghjzPvUU03bIjRCqr4tnfxAVz0JSCsff2QY6yVkZtvc0ITfhxD0wJ Kbk4yq8QyadrtJOjy2pYPH5vn7QnCStZn0YEqDU/yt2C3MeRV0Je1dx9bfdj6towCSV8 AJbtFbIApdS1Wj13abYxJt42tmhdlXzHxngXWU058cazB48K0ZS/cUfFHyLEer1kWLd/ +hKA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v7si5872129plo.12.2019.02.06.04.11.58; Wed, 06 Feb 2019 04:12:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730323AbfBFMKk (ORCPT + 99 others); Wed, 6 Feb 2019 07:10:40 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47030 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727085AbfBFMKk (ORCPT ); Wed, 6 Feb 2019 07:10:40 -0500 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x16C5PR2132409 for ; Wed, 6 Feb 2019 07:10:39 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2qfxsm245w-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 06 Feb 2019 07:10:39 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 6 Feb 2019 12:10:36 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Wed, 6 Feb 2019 12:10:34 -0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x16CAX7C8913254 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Feb 2019 12:10:33 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E72A44204F; Wed, 6 Feb 2019 12:10:32 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 80CD042070; Wed, 6 Feb 2019 12:10:31 +0000 (GMT) Received: from rapoport-lnx (unknown [9.148.8.84]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 6 Feb 2019 12:10:31 +0000 (GMT) Received: by rapoport-lnx (sSMTP sendmail emulation); Wed, 06 Feb 2019 14:10:30 +0200 From: Mike Rapoport To: Andrew Morton Cc: Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: [PATCH 2/2] memblock: split checks whether a region should be skipped to a helper function Date: Wed, 6 Feb 2019 14:10:25 +0200 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549455025-17706-1-git-send-email-rppt@linux.ibm.com> References: <1549455025-17706-1-git-send-email-rppt@linux.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19020612-0016-0000-0000-000002531D6C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19020612-0017-0000-0000-000032AD2650 Message-Id: <1549455025-17706-3-git-send-email-rppt@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-06_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902060096 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The __next_mem_range() and __next_mem_range_rev() duplucate the code that checks whether a region should be skipped because of node or flags incompatibility. Split this code into a helper function. Signed-off-by: Mike Rapoport --- mm/memblock.c | 53 +++++++++++++++++++++++++---------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index af5fe8e..f87d3ae 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -958,6 +958,29 @@ void __init_memblock __next_reserved_mem_region(u64 *idx, *idx = ULLONG_MAX; } +static bool should_skip_region(struct memblock_region *m, int nid, int flags) +{ + int m_nid = memblock_get_region_node(m); + + /* only memory regions are associated with nodes, check it */ + if (nid != NUMA_NO_NODE && nid != m_nid) + return true; + + /* skip hotpluggable memory regions if needed */ + if (movable_node_is_enabled() && memblock_is_hotpluggable(m)) + return true; + + /* if we want mirror memory skip non-mirror memory regions */ + if ((flags & MEMBLOCK_MIRROR) && !memblock_is_mirror(m)) + return true; + + /* skip nomap memory unless we were asked for it explicitly */ + if (!(flags & MEMBLOCK_NOMAP) && memblock_is_nomap(m)) + return true; + + return false; +} + /** * __next__mem_range - next function for for_each_free_mem_range() etc. * @idx: pointer to u64 loop variable @@ -1005,20 +1028,7 @@ void __init_memblock __next_mem_range(u64 *idx, int nid, phys_addr_t m_end = m->base + m->size; int m_nid = memblock_get_region_node(m); - /* only memory regions are associated with nodes, check it */ - if (nid != NUMA_NO_NODE && nid != m_nid) - continue; - - /* skip hotpluggable memory regions if needed */ - if (movable_node_is_enabled() && memblock_is_hotpluggable(m)) - continue; - - /* if we want mirror memory skip non-mirror memory regions */ - if ((flags & MEMBLOCK_MIRROR) && !memblock_is_mirror(m)) - continue; - - /* skip nomap memory unless we were asked for it explicitly */ - if (!(flags & MEMBLOCK_NOMAP) && memblock_is_nomap(m)) + if (should_skip_region(m, nid, flags)) continue; if (!type_b) { @@ -1122,20 +1132,7 @@ void __init_memblock __next_mem_range_rev(u64 *idx, int nid, phys_addr_t m_end = m->base + m->size; int m_nid = memblock_get_region_node(m); - /* only memory regions are associated with nodes, check it */ - if (nid != NUMA_NO_NODE && nid != m_nid) - continue; - - /* skip hotpluggable memory regions if needed */ - if (movable_node_is_enabled() && memblock_is_hotpluggable(m)) - continue; - - /* if we want mirror memory skip non-mirror memory regions */ - if ((flags & MEMBLOCK_MIRROR) && !memblock_is_mirror(m)) - continue; - - /* skip nomap memory unless we were asked for it explicitly */ - if (!(flags & MEMBLOCK_NOMAP) && memblock_is_nomap(m)) + if (should_skip_region(m, nid, flags)) continue; if (!type_b) { -- 2.7.4