From patchwork Wed Aug 16 17:35:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 110271 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp1084327qge; Wed, 16 Aug 2017 10:36:34 -0700 (PDT) X-Received: by 10.98.198.145 with SMTP id x17mr2462103pfk.272.1502904994211; Wed, 16 Aug 2017 10:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502904994; cv=none; d=google.com; s=arc-20160816; b=rSyAli5g5gLduxAULqXvNo7r4Ef+8PkPBfyjmSIooe+VfQmHo3woiHNhppB4HraBTf ceyA82T9R79BouYZzEtaZfp2WyqOVqlM0FsWBH7ruAlXNRcaeK7UqyUIor5ICnC16FzK Q/0ML8BsstrPXhMr8Od+xgjjD6By56yJlvAd9TsFNxZonScg/9ReDqd6vGVRfP8iBvTp ylwI0X4d64RAueYVsZXIr3aR/RUplFViSmE2xfD4PY34XZDIRuO3C9JsBBafijtep9u+ ywH7UnMaK/QrN7lKd/GVP5KvsWVjP51aExp8+8w9oL9YQIToXSYitHMx1IaRA8j9959W wJCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=copj9KTKs0o2xa88ZurH7AhxymSVTM2Ch5VmOei1ZLw=; b=Vnw3PFZu9zqckKBUqWZKqpVi578iFtHE+mgB1q63LRRmrow4zOKkDm1EmCvMRj3Ab2 +hJTnr7npLtIt1k1XcBqNUkyLbMBjx2/EFdy50owDbeft4Qyyub11cwYvBW0iJz37QbA WlP57dNatRjbtx5iQX8Pev1W42qsXc/JhOnFJzrppJYo8fPhN+LwZ4hSvpMWBnEi/ol7 qWKB2b9xN2ul7Mjj5N+oZaracxzY5l7aY9hfx5aHzXlCh0myaIl5NKorIrWMzTPmwtie jKqzXAXU6i/zPueRAJQ7GL+kiXoZMApS4iehd1CBTyae/Dw8Plm0hVck21/WRR7SMh1/ bhdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=XwpY07T+; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t76si760453pgc.63.2017.08.16.10.36.33; Wed, 16 Aug 2017 10:36:34 -0700 (PDT) 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=@pobox.com header.s=sasl header.b=XwpY07T+; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752336AbdHPRgA (ORCPT + 26 others); Wed, 16 Aug 2017 13:36:00 -0400 Received: from pb-smtp1.pobox.com ([64.147.108.70]:59032 "EHLO sasl.smtp.pobox.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751640AbdHPRf6 (ORCPT ); Wed, 16 Aug 2017 13:35:58 -0400 Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 47B31AD79D; Wed, 16 Aug 2017 13:35:57 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:date:message-id; s=sasl; bh=AFEzyseNdalub9CHnLL5FiOS4/g =; b=XwpY07T+VaysZALykOJTwlxIQ4N3OIiW9G8UCMNtS0D/bjR8h+5S3Rahin4 VFUmFL3/GJZq3Gg58I23yXKDXHXkFW3RAhVrcRHC516e5YIqv4PKFTcvdgTMpOIl 3sCjuxqF+AVaORx2Va8s5CkyZtTzbtJB1pGnHstuHfuqjxeg= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id 36670AD79B; Wed, 16 Aug 2017 13:35:57 -0400 (EDT) Received: from yoda.home (unknown [70.80.200.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 9EDD2AD798; Wed, 16 Aug 2017 13:35:56 -0400 (EDT) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTP id 653C12DA050D; Wed, 16 Aug 2017 13:35:55 -0400 (EDT) From: Nicolas Pitre To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-embedded@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Brandt Subject: [PATCH v2 0/5] cramfs refresh for embedded usage Date: Wed, 16 Aug 2017 13:35:31 -0400 Message-Id: <20170816173536.1879-1-nicolas.pitre@linaro.org> X-Mailer: git-send-email 2.9.5 X-Pobox-Relay-ID: 5C3DA970-82A9-11E7-A617-FE4B1A68708C-78420484!pb-smtp1.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This series brings a nice refresh to the cramfs filesystem, adding the following capabilities: - Direct memory access, bypassing the block and/or MTD layers entirely. - Ability to store individual data blocks uncompressed. - Ability to locate individual data blocks anywhere in the filesystem. The end result is a very tight filesystem that can be accessed directly from ROM without any other subsystem underneath. Also this allows for user space XIP which is a very important feature for tiny embedded systems. Why cramfs? Because cramfs is very simple and small. With CONFIG_CRAMFS_BLOCK=n and CONFIG_CRAMFS_PHYSMEM=y the cramfs driver may use as little as 3704 bytes of code. That's many times smaller than squashfs. And the runtime memory usage is also much less with cramfs than squashfs. It packs very tightly already compared to romfs which has no compression support. And the cramfs format was simple to extend, allowing for both compressed and uncompressed blocks within the same file. Why not accessing ROM via MTD? The MTD layer is nice and flexible. It also represents a huge overhead considering its core with no other enabled options weights 19KB. That's many times the size of the cramfs code for something that essentially boils down to a glorified argument parser and a call to memremap() in this case. And if someone still wants to use cramfs via MTD then it is already possible with mtdblock. Why not using DAX? DAX stands for "Direct Access" and is a generic kernel layer helping with the necessary tasks involved with XIP. It is tailored for large writable filesystems and relies on the presence of an MMU. It also has the following shortcoming: "The DAX code does not work correctly on architectures which have virtually mapped caches such as ARM, MIPS and SPARC." That makes it unsuitable for a large portion of the intended targets for this series. And due to the read-only nature of cramfs, it is possible to achieve the intended result with a much simpler approach making DAX somewhat overkill in this context. The maximum size of a cramfs image can't exceed 272MB. In practice it is likely to be much much less. Given this series is concerned with small memory systems, even in the MMU case there is always plenty of vmalloc space left to map it all and even a 272MB memremap() wouldn't be a problem. If it is then maybe your system is big enough with large resources to manage already and you're pretty unlikely to be using cramfs in the first place. Of course, while this cramfs remains backward compatible with existing filesystem images, a newer mkcramfs version is necessary to take advantage of the extended data layout. I created a version of mkcramfs that detects ELF files and marks text+rodata segments for XIP and compresses the rest of those ELF files automatically. So here it is. I'm also willing to step up as cramfs maintainer given that no sign of any maintenance activities appeared for years. This series is also available based on v4.13-rc4 via git here: http://git.linaro.org/people/nicolas.pitre/linux xipcramfs Changes from v1: - Improved mmap() support by adding the ability to partially populate a mapping and lazily split the non directly mapable pages to a separate vma at fault time (thanks to Chris Brandt for testing). - Clarified the documentation some more. diffstat: Documentation/filesystems/cramfs.txt | 42 ++ MAINTAINERS | 4 +- fs/cramfs/Kconfig | 39 +- fs/cramfs/README | 31 +- fs/cramfs/inode.c | 621 +++++++++++++++++++++++++---- include/uapi/linux/cramfs_fs.h | 20 +- init/do_mounts.c | 8 + 7 files changed, 688 insertions(+), 77 deletions(-) Tested-by: Chris Brandt