Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3583752imu; Tue, 18 Dec 2018 00:25:11 -0800 (PST) X-Google-Smtp-Source: AFSGD/XG2FxY593uB3iV2rf5EAe9tGOVy7IzaOYC0twlRPP/aKprVuSlk++EKRj7sQA1+g8GZktS X-Received: by 2002:a62:db41:: with SMTP id f62mr16097338pfg.123.1545121511395; Tue, 18 Dec 2018 00:25:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545121511; cv=none; d=google.com; s=arc-20160816; b=ev+cahzDJSa6qJ7SJxG1gK3HMpexPQg+bhFtqAVMyAe9Bd05lhrRPEGRe+PXLYcubb bB77+apEMCOA8doumJXJZ54Gs8fayTcWMjIeSR27C30xG4VFjFCctaoWeAuD5Zkyb15/ /BBPxIZDOzZflFyCPDBnplUpN0GmhXXaMLMxFUbgPgjYU6sknvI4qfdkcUwVLgpp0x5b jphVVm+jiII0Xo1UeC4Xke7RIYlLNjXpYl7h7lWr0QLe9fIo2mnJayrQdf631hXkL603 zKOl7xkA8N2g9b6SJ1epUgVKDmVoLDQoSWu49C1LojE6iZo/MAu2WVpVKmaVbXdvLW1c S65A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=juX3lDoH7A5it30MWKVRBo5WuBz2pCJl9gskcMHPCiM=; b=NmsMaBzSkyYTXBlrGDlCEa1IR89Z/XdkFF0GoaWhVZxK8QEK59JJDbDiadDt8loqoF NFKBkeQ05B9ICZOUK4xhw9U7riqhVrt7APS6WTGvpBwK8UB79Agv3brsBZBDyQkw4DoR 4mPW1UZtnqKOHs1eM6RAv6uxP4F0KdcOiHs12W6CgPgEeqqd92akGmvGjY5nCMqgiJka 6/y3SEFs/sLNQ9L8qnyTnd+A9LnGNz2RFs0YwfO1m/Hf3O/OqjqXvzZ+3VpdgOzDUkU5 s80dwemiq9Sfd/F+/WmFk6E4/484v4XJXzAr0vnH39EXt0qa/EhhwoX7fb0Em+blA3U3 0Jtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=lajsVGxx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j191si13065472pgc.15.2018.12.18.00.24.56; Tue, 18 Dec 2018 00:25:11 -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; dkim=pass header.i=@brainfault-org.20150623.gappssmtp.com header.s=20150623 header.b=lajsVGxx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726616AbeLRIXh (ORCPT + 99 others); Tue, 18 Dec 2018 03:23:37 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:41645 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726316AbeLRIXh (ORCPT ); Tue, 18 Dec 2018 03:23:37 -0500 Received: by mail-wr1-f68.google.com with SMTP id x10so14900546wrs.8 for ; Tue, 18 Dec 2018 00:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brainfault-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=juX3lDoH7A5it30MWKVRBo5WuBz2pCJl9gskcMHPCiM=; b=lajsVGxxldceawDDkpcCgG3vh5Kpr8QYrp1CSkqFZQcpoHILBy+P1RhIDX6CcUjQsV p1aixERN75JLkdnkCkAA3nfc6sDu6Ex8+cYaDZyQaOf4EZv6mG2ZbjVtoZ8LA9VTkPDu 5qfUttVFtPRmsBVGMtEDn5c2OWWHACy1dOYCAjz5lMUVKHt9qlHzeSbaHTjx+qbBo7bo 4HaR+hMJiiaJ6IS/qj8lzRTdtL4RupZphkP8EageH84Bwdey2/xXAdVOL4guo5EvqPoW mEI92DpcEEzx2QilSd9kPgv+PP41KkgTdzjnCnffHpMyXBJ3UOQ9DMN0JqVexiDxtl/0 tmGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=juX3lDoH7A5it30MWKVRBo5WuBz2pCJl9gskcMHPCiM=; b=cj4MyzLcMP13L4yU95OaTTPOmmoIAxfUiT0ZW2K6Q5/dlg21LmLdiHEKLjVdGGq8fX GNUssgu8kmeTykeT98bcedr8vVZAgB6/SZERDtvB5By3orQRnUQX9J1KRxh2eyvZ+Nt0 B5rMNHa4Evp1F7YRk0YbDV8MvWrMz0W154knk4wsCde0k855bN+zNf0HhTOJb7x4iNi4 /nH4QnqvkBTCJfRIw0GPpUcxvU5GHdEVm3EdRtOV9hbdxK7qW19oO48S2FfCf9Mvwpb5 EZE4xOSi1J1lZjeE6Owp7CEBTYz4dKU9adO0c7+K8S6d9xXXZ8aJ1d4/QHNqI0ldRWIi l2dw== X-Gm-Message-State: AA+aEWajsb4pyndl33vEE/f3d/+bLywslOJ+28PcIQT6d7HZSdUFxuaX YJAPp9FKqYV1a+EN3IotWyd4bVcEDyiWLMlhQmLNWA== X-Received: by 2002:adf:ee07:: with SMTP id y7mr14178135wrn.187.1545121415078; Tue, 18 Dec 2018 00:23:35 -0800 (PST) MIME-Version: 1.0 References: <20181126060802.19314-1-anup@brainfault.org> <587bbe80f25203e6122dfcc0eadba50b@mailhost.ics.forth.gr> In-Reply-To: <587bbe80f25203e6122dfcc0eadba50b@mailhost.ics.forth.gr> From: Anup Patel Date: Tue, 18 Dec 2018 13:53:23 +0530 Message-ID: Subject: Re: [PATCH] RISC-V: Make BSS section as the last section in vmlinux.lds.S To: Nick Kossifidis Cc: Palmer Dabbelt , Albert Ou , Christoph Hellwig , Atish Patra , linux-riscv@lists.infradead.org, "linux-kernel@vger.kernel.org List" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 17, 2018 at 6:29 PM Nick Kossifidis wrote: > > =CE=A3=CF=84=CE=B9=CF=82 2018-12-17 11:36, Anup Patel =CE=AD=CE=B3=CF=81= =CE=B1=CF=88=CE=B5: > > On Mon, Nov 26, 2018 at 11:42 AM Anup Patel > > wrote: > >> > >> The objcopy only emits loadable sections when creating flat kernel > >> Image. To have minimal possible size of flat kernel Image, we should > >> have all non-loadable sections after loadable sections. > >> > >> Currently, execption table section (loadable section) is after BSS > >> section (non-loadable section) in the RISC-V vmlinux.lds.S. This > >> is not optimal for having minimal flat kernel Image size hence this > >> patch makes BSS section as the last section in RISC-V vmlinux.lds.S. > >> > >> In addition, we make BSS section aligned to 16byte instead of PAGE > >> aligned which further reduces flat kernel Image size by few KBs. > >> > >> The flat kernel Image size of Linux-4.20-rc4 using GCC 8.2.0 is > >> 8819980 bytes with current RISC-V vmlinux.lds.S and it reduces to > >> 7991740 bytes with this patch applied using GCC 8.2.0. In summary, > >> this patch reduces Linux-4.20-rc4 flat kernel Image size by 809 KB. > >> > >> Signed-off-by: Anup Patel > >> --- > >> arch/riscv/kernel/vmlinux.lds.S | 4 ++-- > >> 1 file changed, 2 insertions(+), 2 deletions(-) > >> > >> diff --git a/arch/riscv/kernel/vmlinux.lds.S > >> b/arch/riscv/kernel/vmlinux.lds.S > >> index 65df1dfdc303..cc99eed44931 100644 > >> --- a/arch/riscv/kernel/vmlinux.lds.S > >> +++ b/arch/riscv/kernel/vmlinux.lds.S > >> @@ -74,8 +74,6 @@ SECTIONS > >> *(.sbss*) > >> } > >> > >> - BSS_SECTION(PAGE_SIZE, PAGE_SIZE, 0) > >> - > >> EXCEPTION_TABLE(0x10) > >> NOTES > >> > >> @@ -83,6 +81,8 @@ SECTIONS > >> *(.rel.dyn*) > >> } > >> > >> + BSS_SECTION(0x10, 0x10, 0x10) > >> + > >> _end =3D .; > >> > >> STABS_DEBUG > >> -- > >> 2.17.1 > >> > > > > Hi All, > > > > Any comment on this patch? > > > > Regards, > > Anup > > > > Just a note on coding style, you should be using a macro instead of 0x10 > so that those who read the code can understand what it is and also a few > comments since searching through the commit logs to understand why you > used it isn't optimal. RISC-V can support 32bit, 64bit and 128bit machine-word sizes. The 0x10 number is the machine-word size in bytes for 128bit RISC-V CPU (i.e. maximum machine-word size). I will add a macro MAX_BYTES_PER_LONG in vmlinux.lds.S and use it in-place of 0x10 Regards, Anup