From patchwork Mon Aug 6 10:52:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Rapoport X-Patchwork-Id: 10556817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1058A13B4 for ; Mon, 6 Aug 2018 10:53:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1B38291CE for ; Mon, 6 Aug 2018 10:53:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E559F291EE; Mon, 6 Aug 2018 10:53:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36606291CE for ; Mon, 6 Aug 2018 10:53:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D39B6B0272; Mon, 6 Aug 2018 06:53:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 55D036B0273; Mon, 6 Aug 2018 06:53:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3FD7B6B0274; Mon, 6 Aug 2018 06:53:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by kanga.kvack.org (Postfix) with ESMTP id D492D6B0272 for ; Mon, 6 Aug 2018 06:53:03 -0400 (EDT) Received: by mail-ed1-f69.google.com with SMTP id g11-v6so3890703edi.8 for ; Mon, 06 Aug 2018 03:53:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:in-reply-to:references:message-id; bh=FlNoTNQMOT4iy/rnXm9Q3ArF/PUrkwkGocJAK1A0JLY=; b=nuCKn7L/+xOHRSyfVlNWcHS+PdfXGIhin81Va2ZnKWeBLNKxsof1gar2M8rr4BiSQc nwTCPjWIdiZkiWc7hsQgCwsPGnLHTkNMysPxK57ouGoKoaOhj31ybkJKL7Ty1BsSMXLB VGMXFaGd4DmUv6DtADTZ5OqUwutqsmUvWoYVV+cbxJH9amYHZepPDTuUpibY/EmH6NqM PIY2LbSJKSSr+l92QAjHfaXVh3BRZjM+ELRe5Np2diGCrbJLjIhhiR1IN3Mgy2GaBdST 8Wm0PtADDrTZtO6mKzgmOjNMP9CEuF/fnKGwvYeYoAWO/PO2K+IL3iAKkvOy3HXTFU9B yUYw== X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AOUpUlE9LFya1/6RgNsGuhHYYdaKm0HnDycS/wnKNh+wTE8PLAlx3Ry/ K1GnsyVklyvBhfaRmCMbxfFKb82GIIjR10fyRIuTrDd/eP9kD2c56wN9JX82K+BIz47CXxarXf4 gTUV63sPuOhSsAeZOKXCBia9o/gYDVExPFTT8xu1o2oBKEnUM/A8M8NQHJx/mKz8= X-Received: by 2002:a50:9356:: with SMTP id n22-v6mr17395322eda.206.1533552783376; Mon, 06 Aug 2018 03:53:03 -0700 (PDT) X-Google-Smtp-Source: AAOMgpciSmPDNM28DT7kgT4XP7juoHilcF1i9UqqP1trf20jb2U0F4Hy0YCT+CeTP57K+k/wcYne X-Received: by 2002:a50:9356:: with SMTP id n22-v6mr17395274eda.206.1533552782534; Mon, 06 Aug 2018 03:53:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533552782; cv=none; d=google.com; s=arc-20160816; b=p2jPwmE5n7CXXLRYiTcuD7ixhtipWcVCjsUDuK8Pff5LyAlR+VEJ90Zs2Vn9/CTzrt EE8+aOJAxuZTVlXGx0DLWoxxjgbF5wQi6mw2yQrAzld8hc1r8UwW8F4xucvNMhKu/s4m eDqaohnXpN9RDGcEO0H/KnHyMFtygUPY/G4TKK+f4WaO71IHVF2XizgO/HopCrAg0gMo G2z8SaQaHwyrwWD+3W3u5Yzhtt4fPd+KjuFoV5BNdgwhM3sbsRBDg3GKlaZKwoXIf/NI pJKtvmyrch+5OoiYo+QEpwTX2hIcC6j5FBrjRXgBU8kB14HvjLzk0ZueDo4ccZAjL0xk vrUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:references:in-reply-to:date:subject:cc:to:from :arc-authentication-results; bh=FlNoTNQMOT4iy/rnXm9Q3ArF/PUrkwkGocJAK1A0JLY=; b=MoCSxATmIvjdLe9B5FDXnedY5rmp3YgIs7R6Ia640H4+tB0hB+ediGKu/Ko5+5sEp3 nSpUoaTW5vER8y85/JsE5AyuuWMMyVb4xSiHEVsyu3lNpXXPsO7WAgDT6WeThr/aAldY cS/kkoL2yjrL18hc9NFILCJKr1RUY77TFL8vgFKMz5Ko0yqtJbV1QvF8xs4xKIuh/D3P MSBUK+W3L2Mn/vWlZUF1P+azzzFrgbulvJSKt9un74YRKDU7SYnVCEEPFrW4YrQKt1Xb 5VSWV7pySgwqn1WhCj0oWg4AxwchLW43UozwDT8LwBxys5jdUiGSrZnl/XXk9l59VQHE uzwg== ARC-Authentication-Results: i=1; mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com. [148.163.156.1]) by mx.google.com with ESMTPS id w49-v6si1490311edm.138.2018.08.06.03.53.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 03:53:02 -0700 (PDT) Received-SPF: neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) client-ip=148.163.156.1; Authentication-Results: mx.google.com; spf=neutral (google.com: 148.163.156.1 is neither permitted nor denied by best guess record for domain of rppt@linux.vnet.ibm.com) smtp.mailfrom=rppt@linux.vnet.ibm.com; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w76An4Ah107994 for ; Mon, 6 Aug 2018 06:53:00 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kpm971nb4-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 06 Aug 2018 06:52:59 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 6 Aug 2018 11:52:55 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 6 Aug 2018 11:52:53 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w76AqqvI10420372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 6 Aug 2018 10:52:52 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CD21211C05C; Mon, 6 Aug 2018 13:53:00 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6D34711C04A; Mon, 6 Aug 2018 13:52:58 +0100 (BST) Received: from rapoport-lnx (unknown [9.148.8.115]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 6 Aug 2018 13:52:58 +0100 (BST) Received: by rapoport-lnx (sSMTP sendmail emulation); Mon, 06 Aug 2018 13:52:48 +0300 From: Mike Rapoport To: "David S. Miller" Cc: Sam Ravnborg , Michal Hocko , sparclinux@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Mike Rapoport Subject: [PATCH v2 3/3] sparc32: split ramdisk detection and reservation to a helper function Date: Mon, 6 Aug 2018 13:52:35 +0300 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533552755-16679-1-git-send-email-rppt@linux.vnet.ibm.com> References: <1533552755-16679-1-git-send-email-rppt@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18080610-0028-0000-0000-000002E62309 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18080610-0029-0000-0000-0000239E4474 Message-Id: <1533552755-16679-4-git-send-email-rppt@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-06_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1807170000 definitions=main-1808060117 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: X-Virus-Scanned: ClamAV using ClamSMTP The detection and reservation of ramdisk memory were separated to allow bootmem bitmap initialization after the ramdisk boundaries are detected. Since the bootmem initialization is removed, the reservation of ramdisk memory is done immediately after its boundaries are found. Split the entire block into a separate helper function. Signed-off-by: Mike Rapoport Suggested-by: Sam Ravnborg Reviewed-by: Sam Ravnborg --- arch/sparc/mm/init_32.c | 56 +++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c index e786fe0..92634d4 100644 --- a/arch/sparc/mm/init_32.c +++ b/arch/sparc/mm/init_32.c @@ -102,6 +102,36 @@ static unsigned long calc_max_low_pfn(void) return tmp; } +static void __init find_ramdisk(unsigned long end_of_phys_memory) +{ +#ifdef CONFIG_BLK_DEV_INITRD + unsigned long size; + + /* Now have to check initial ramdisk, so that it won't pass + * the end of memory + */ + if (sparc_ramdisk_image) { + if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE) + sparc_ramdisk_image -= KERNBASE; + initrd_start = sparc_ramdisk_image + phys_base; + initrd_end = initrd_start + sparc_ramdisk_size; + if (initrd_end > end_of_phys_memory) { + printk(KERN_CRIT "initrd extends beyond end of memory " + "(0x%016lx > 0x%016lx)\ndisabling initrd\n", + initrd_end, end_of_phys_memory); + initrd_start = 0; + } else { + /* Reserve the initrd image area. */ + size = initrd_end - initrd_start; + memblock_reserve(initrd_start, size); + + initrd_start = (initrd_start - phys_base) + PAGE_OFFSET; + initrd_end = (initrd_end - phys_base) + PAGE_OFFSET; + } + } +#endif +} + unsigned long __init bootmem_init(unsigned long *pages_avail) { unsigned long start_pfn, bytes_avail, size; @@ -160,32 +190,8 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) high_pages >> (20 - PAGE_SHIFT)); } -#ifdef CONFIG_BLK_DEV_INITRD - /* Now have to check initial ramdisk, so that it won't pass - * the end of memory - */ - if (sparc_ramdisk_image) { - if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE) - sparc_ramdisk_image -= KERNBASE; - initrd_start = sparc_ramdisk_image + phys_base; - initrd_end = initrd_start + sparc_ramdisk_size; - if (initrd_end > end_of_phys_memory) { - printk(KERN_CRIT "initrd extends beyond end of memory " - "(0x%016lx > 0x%016lx)\ndisabling initrd\n", - initrd_end, end_of_phys_memory); - initrd_start = 0; - } - } - - if (initrd_start) { - /* Reserve the initrd image area. */ - size = initrd_end - initrd_start; - memblock_reserve(initrd_start, size); + find_ramdisk(end_of_phys_memory); - initrd_start = (initrd_start - phys_base) + PAGE_OFFSET; - initrd_end = (initrd_end - phys_base) + PAGE_OFFSET; - } -#endif /* Reserve the kernel text/data/bss. */ size = (start_pfn << PAGE_SHIFT) - phys_base; memblock_reserve(phys_base, size);