Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751851AbdHPLIi (ORCPT ); Wed, 16 Aug 2017 07:08:38 -0400 Received: from relmlor2.renesas.com ([210.160.252.172]:26471 "EHLO relmlie1.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751530AbdHPLIg (ORCPT ); Wed, 16 Aug 2017 07:08:36 -0400 X-IronPort-AV: E=Sophos;i="5.41,382,1498489200"; d="scan'208";a="253650140" From: Chris Brandt To: Nicolas Pitre CC: Alexander Viro , "linux-fsdevel@vger.kernel.org" , "linux-embedded@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH 0/5] cramfs refresh for embedded usage Thread-Topic: [PATCH 0/5] cramfs refresh for embedded usage Thread-Index: AQHTEtdFT0/wwlN9sk6l1Kak7eVmpaKEGObggAAH1ICAAAY+sIAABmYAgAAD8RCAAKHFAIAAcXMQgAExywCAAF5O0A== Date: Wed, 16 Aug 2017 11:08:30 +0000 Message-ID: References: <20170811192252.19062-1-nicolas.pitre@linaro.org> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Chris.Brandt@renesas.com; x-originating-ip: [75.60.247.61] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;SG2PR06MB0443;20:IOT6bema4347PVq0pHr617eyJSOQzxYwk+2FlB2ruW20f8WgRYbbChz+0HVH7nQOXMRVdSb58z578yIWUF4kAK7B7BxG64jp28Av2dx2W+hUCTszn4G0rFpIA29A1fYVQB1V/ssN26aPmO7S/QOraveKM5NT0dGBpxrZlbQo/QY= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 3b4bfec8-a392-42ef-b555-08d4e4972101 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(48565401081)(2017052603031)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095);SRVR:SG2PR06MB0443; x-ms-traffictypediagnostic: SG2PR06MB0443: x-exchange-antispam-report-test: UriScan:; x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123560025)(20161123562025)(20161123555025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:SG2PR06MB0443;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:SG2PR06MB0443; x-forefront-prvs: 0401647B7F x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39860400002)(24454002)(199003)(189002)(69234005)(101416001)(7696004)(7736002)(68736007)(229853002)(575784001)(25786009)(110136004)(478600001)(74316002)(8936002)(5250100002)(81156014)(33656002)(8676002)(93886004)(6506006)(4326008)(6916009)(53936002)(14454004)(2950100002)(5660300001)(55016002)(54906002)(72206003)(2906002)(3280700002)(97736004)(9686003)(6246003)(50986999)(345774005)(76176999)(189998001)(54356999)(6436002)(99286003)(3846002)(81166006)(102836003)(86362001)(6116002)(66066001)(3660700001)(305945005)(105586002)(2900100001)(106356001);DIR:OUT;SFP:1102;SCL:1;SRVR:SG2PR06MB0443;H:SG2PR06MB1165.apcprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Aug 2017 11:08:30.8604 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 53d82571-da19-47e4-9cb4-625a166a4a2a X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB0443 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v7GB8iPl005838 Content-Length: 3274 Lines: 81 On Wednesday, August 16, 2017, Nicolas Pitre wrote: > > Yes, now I can boot with my rootfs being a XIP cramfs. > > > > However, like you said, libc is not XIP. > > I think I have it working now. Probably learned more about the memory > management internals than I ever wanted to know. Please try the patch > below on top of all the previous ones. If it works for you as well then > I'll rebase and repost the whole thing. > > diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c > index 4c7f01fcd2..0b651f985c 100644 > --- a/fs/cramfs/inode.c > +++ b/fs/cramfs/inode.c Yes, that worked. Very nice! $ cat /proc/self/maps 00008000-000a1000 r-xp 1b005000 00:0c 18192 /bin/busybox 000a9000-000aa000 rw-p 00099000 00:0c 18192 /bin/busybox 000aa000-000ac000 rw-p 00000000 00:00 0 [heap] b6e23000-b6efc000 r-xp 1b0bc000 00:0c 766540 /lib/libc-2.18-2013.10.so b6efc000-b6f04000 ---p 1b195000 00:0c 766540 /lib/libc-2.18-2013.10.so b6f04000-b6f06000 r--p 000d9000 00:0c 766540 /lib/libc-2.18-2013.10.so b6f06000-b6f07000 rw-p 000db000 00:0c 766540 /lib/libc-2.18-2013.10.so b6f07000-b6f0a000 rw-p 00000000 00:00 0 b6f0a000-b6f21000 r-xp 1b0a4000 00:0c 670372 /lib/ld-2.18-2013.10.so b6f24000-b6f25000 rw-p 00000000 00:00 0 b6f26000-b6f28000 rw-p 00000000 00:00 0 b6f28000-b6f29000 r--p 00016000 00:0c 670372 /lib/ld-2.18-2013.10.so b6f29000-b6f2a000 rw-p 00017000 00:0c 670372 /lib/ld-2.18-2013.10.so be877000-be898000 rw-p 00000000 00:00 0 [stack] beba9000-bebaa000 r-xp 00000000 00:00 0 [sigpage] ffff0000-ffff1000 r-xp 00000000 00:00 0 [vectors] Just FYI, I'm running an xipImage with all the RZ/A1 upstream drivers enabled and only using about 4.5MB of total system RAM. That's pretty good. Of course for a real application, you would trim off the drivers and subsystems you don't plan on using, thus lowering your RAM usage. > +/* > + * It is possible for cramfs_physmem_mmap() to partially populate the > mapping > + * causing page faults in the unmapped area. When that happens, we need > to > + * split the vma so that the unmapped area gets its own vma that can be > backed > + * with actual memory pages and loaded normally. This is necessary > because > + * remap_pfn_range() overwrites vma->vm_pgoff with the pfn and > filemap_fault() > + * no longer works with it. Furthermore this makes /proc/x/maps right. > + * Q: is there a way to do split vma at mmap() time? > + */ So if I understand correctly, the issue is that sometimes you only have a partial PAGE worth that you need to map. Correct? For the AXFS file system, XIP page mapping was done on a per page decision, not per file. So the mkfs.axfs tool would only mark a page as XIP if the entire section would fit in a complete PAGE. If for example you had a partial page at the end of a multi page code segment, it would put that partial page in a separate portion of the AXFS image and be marked as 'copy to RAM' instead of being marked as 'map as XIP'. So in the AXFS case, it was a combination of the creation tool and file system driver features to fix the partial page issue. Not sure if any of this info is relevant, but I thought I would mention anyway. Thank you for your efforts on adding XIP to cramfs! Chris