linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-media@vger.kernel.org, linux-mm@kvack.org,
	linaro-mm-sig@lists.linaro.org, Ohad Ben-Cohen <ohad@wizery.com>,
	Daniel Walker <dwalker@codeaurora.org>,
	Russell King <linux@arm.linux.org.uk>,
	Arnd Bergmann <arnd@arndb.de>, Jonathan Corbet <corbet@lwn.net>,
	Mel Gorman <mel@csn.ul.ie>, Michal Nazarewicz <mina86@mina86.com>,
	Dave Hansen <dave@linux.vnet.ibm.com>,
	Jesse Barker <jesse.barker@linaro.org>,
	Kyungmin Park <kyungmin.park@samsung.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Rob Clark <rob.clark@linaro.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	DL-SHA-WorkGroupLinux <workgroup.linux@csr.com>
Subject: Re: [Linaro-mm-sig] [PATCHv23 00/16] Contiguous Memory Allocator
Date: Wed, 29 Feb 2012 17:35:42 +0800	[thread overview]
Message-ID: <CAGsJ_4wgVcVjtAa6Qpki=8jSON7MfwJ8yumJ1YXE5p8L3PqUzw@mail.gmail.com> (raw)
In-Reply-To: <1329929337-16648-1-git-send-email-m.szyprowski@samsung.com>

2012/2/23 Marek Szyprowski <m.szyprowski@samsung.com>:
> Hi,
>
> This is (yet another) quick update of CMA patches. I've rebased them
> onto next-20120222 tree from
> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git and
> fixed the bug pointed by Aaro Koskinen.

For the whole series:

Tested-by: Barry Song <Baohua.Song@csr.com>

and i also write a simple kernel helper to test the CMA:

/*
 * kernek module helper for testing CMA
 *
 * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
 *
 * Licensed under GPLv2 or later.
 */

#include <linux/module.h>
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/dma-mapping.h>

#define CMA_NUM  10
static struct device *cma_dev;
static dma_addr_t dma_phys[CMA_NUM];
static void *dma_virt[CMA_NUM];

/* any read request will free coherent memory, eg.
 * cat /dev/cma_test
 */
static ssize_t
cma_test_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
{
	int i;

	for (i = 0; i < CMA_NUM; i++) {
		if (dma_virt[i]) {
			dma_free_coherent(cma_dev, (i + 1) * SZ_1M, dma_virt[i], dma_phys[i]);
			_dev_info(cma_dev, "free virt: %p phys: %p\n", dma_virt[i], (void
*)dma_phys[i]);
			dma_virt[i] = NULL;
			break;
		}
	}
	return 0;
}

/*
 * any write request will alloc coherent memory, eg.
 * echo 0 > /dev/cma_test
 */
static ssize_t
cma_test_write(struct file *file, const char __user *buf, size_t
count, loff_t *ppos)
{
	int i;
	int ret;

	for (i = 0; i < CMA_NUM; i++) {
		if (!dma_virt[i]) {
			dma_virt[i] = dma_alloc_coherent(cma_dev, (i + 1) * SZ_1M,
&dma_phys[i], GFP_KERNEL);

			if (dma_virt[i])
				_dev_info(cma_dev, "alloc virt: %p phys: %p\n", dma_virt[i], (void
*)dma_phys[i]);
			else {
				dev_err(cma_dev, "no mem in CMA area\n");
				ret = -ENOMEM;
			}
			break;
		}
	}

	return count;
}

static const struct file_operations cma_test_fops = {
	.owner =    THIS_MODULE,
	.read  =    cma_test_read,
	.write =    cma_test_write,
};

static struct miscdevice cma_test_misc = {
	.name = "cma_test",
	.fops = &cma_test_fops,
};

static int __init cma_test_init(void)
{
	int ret = 0;

	ret = misc_register(&cma_test_misc);
	if (unlikely(ret)) {
		pr_err("failed to register cma test misc device!\n");
		return ret;
	}
	cma_dev = cma_test_misc.this_device;
	cma_dev->coherent_dma_mask = ~0;
	_dev_info(cma_dev, "registered.\n");

	return ret;
}
module_init(cma_test_init);

static void __exit cma_test_exit(void)
{
	misc_deregister(&cma_test_misc);
}
module_exit(cma_test_exit);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Barry Song <Baohua.Song@csr.com>");
MODULE_DESCRIPTION("kernel module to help the test of CMA");
MODULE_ALIAS("CMA test");

While fulfilling "dd if=/dev/mmcblk0 of=/dev/null bs=4096
count=1024000000 &" and "dd if=/dev/zero of=/data/1 bs=4096
count=1024000000 &" to exhaust memory at background,
i alloc the contiguous memories using the cma_test driver:
$echo 0 > /dev/cma_test
[   16.582216] misc cma_test: alloc virt: ceb00000 phys: 0eb00000
$echo 0 > /dev/cma_test
[   20.843395] misc cma_test: alloc virt: cec00000 phys: 0ec00000
$echo 0 > /dev/cma_test
[   21.774601] misc cma_test: alloc virt: cee00000 phys: 0ee00000
$echo 0 > /dev/cma_test
[   22.925633] misc cma_test: alloc virt: cf100000 phys: 0f100000

i did see the page write back is executed and contiguous memories are
always available.

P.S. the whole series was also back ported to 2.6.38.8 which our
release is based on.

>
> Best regards
> Marek Szyprowski
> Samsung Poland R&D Center
>
> Links to previous versions of the patchset:
> v22: <http://www.spinics.net/lists/linux-media/msg44370.html>
> v21: <http://www.spinics.net/lists/linux-media/msg44155.html>
> v20: <http://www.spinics.net/lists/linux-mm/msg29145.html>
> v19: <http://www.spinics.net/lists/linux-mm/msg29145.html>
> v18: <http://www.spinics.net/lists/linux-mm/msg28125.html>
> v17: <http://www.spinics.net/lists/arm-kernel/msg148499.html>
> v16: <http://www.spinics.net/lists/linux-mm/msg25066.html>
> v15: <http://www.spinics.net/lists/linux-mm/msg23365.html>
> v14: <http://www.spinics.net/lists/linux-media/msg36536.html>
> v13: (internal, intentionally not released)
> v12: <http://www.spinics.net/lists/linux-media/msg35674.html>
> v11: <http://www.spinics.net/lists/linux-mm/msg21868.html>
> v10: <http://www.spinics.net/lists/linux-mm/msg20761.html>
>  v9: <http://article.gmane.org/gmane.linux.kernel.mm/60787>
>  v8: <http://article.gmane.org/gmane.linux.kernel.mm/56855>
>  v7: <http://article.gmane.org/gmane.linux.kernel.mm/55626>
>  v6: <http://article.gmane.org/gmane.linux.kernel.mm/55626>
>  v5: (intentionally left out as CMA v5 was identical to CMA v4)
>  v4: <http://article.gmane.org/gmane.linux.kernel.mm/52010>
>  v3: <http://article.gmane.org/gmane.linux.kernel.mm/51573>
>  v2: <http://article.gmane.org/gmane.linux.kernel.mm/50986>
>  v1: <http://article.gmane.org/gmane.linux.kernel.mm/50669>
>
>
> Changelog:
>
> v23:
>    1. fixed bug spotted by Aaro Koskinen (incorrect check inside VM_BUG_ON)
>
>    2. rebased onto next-20120222 tree from
>       git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
>
> v22:
>    1. Fixed compilation break caused by missing fixup patch in v21
>
>    2. Fixed typos in the comments
>
>    3. Removed superfluous #include entries
>
> v21:
>    1. Fixed incorrect check which broke memory compaction code
>
>    2. Fixed hacky and racy min_free_kbytes handling
>
>    3. Added serialization patch to watermark calculation
>
>    4. Fixed typos here and there in the comments
>
> v20 and earlier - see previous patchsets.
>
>
> Patches in this patchset:
>
> Marek Szyprowski (6):
>  mm: extract reclaim code from __alloc_pages_direct_reclaim()
>  mm: trigger page reclaim in alloc_contig_range() to stabilise
>    watermarks
>  drivers: add Contiguous Memory Allocator
>  X86: integrate CMA with DMA-mapping subsystem
>  ARM: integrate CMA with DMA-mapping subsystem
>  ARM: Samsung: use CMA for 2 memory banks for s5p-mfc device
>
> Mel Gorman (1):
>  mm: Serialize access to min_free_kbytes
>
> Michal Nazarewicz (9):
>  mm: page_alloc: remove trailing whitespace
>  mm: compaction: introduce isolate_migratepages_range()
>  mm: compaction: introduce map_pages()
>  mm: compaction: introduce isolate_freepages_range()
>  mm: compaction: export some of the functions
>  mm: page_alloc: introduce alloc_contig_range()
>  mm: page_alloc: change fallbacks array handling
>  mm: mmzone: MIGRATE_CMA migration type added
>  mm: page_isolation: MIGRATE_CMA isolation functions added
>
>  Documentation/kernel-parameters.txt   |    9 +
>  arch/Kconfig                          |    3 +
>  arch/arm/Kconfig                      |    2 +
>  arch/arm/include/asm/dma-contiguous.h |   15 ++
>  arch/arm/include/asm/mach/map.h       |    1 +
>  arch/arm/kernel/setup.c               |    9 +-
>  arch/arm/mm/dma-mapping.c             |  369 ++++++++++++++++++++++++------
>  arch/arm/mm/init.c                    |   23 ++-
>  arch/arm/mm/mm.h                      |    3 +
>  arch/arm/mm/mmu.c                     |   31 ++-
>  arch/arm/plat-s5p/dev-mfc.c           |   51 +----
>  arch/x86/Kconfig                      |    1 +
>  arch/x86/include/asm/dma-contiguous.h |   13 +
>  arch/x86/include/asm/dma-mapping.h    |    4 +
>  arch/x86/kernel/pci-dma.c             |   18 ++-
>  arch/x86/kernel/pci-nommu.c           |    8 +-
>  arch/x86/kernel/setup.c               |    2 +
>  drivers/base/Kconfig                  |   89 +++++++
>  drivers/base/Makefile                 |    1 +
>  drivers/base/dma-contiguous.c         |  401 +++++++++++++++++++++++++++++++
>  include/asm-generic/dma-contiguous.h  |   28 +++
>  include/linux/device.h                |    4 +
>  include/linux/dma-contiguous.h        |  110 +++++++++
>  include/linux/gfp.h                   |   12 +
>  include/linux/mmzone.h                |   47 +++-
>  include/linux/page-isolation.h        |   18 +-
>  mm/Kconfig                            |    2 +-
>  mm/Makefile                           |    3 +-
>  mm/compaction.c                       |  418 +++++++++++++++++++++------------
>  mm/internal.h                         |   33 +++
>  mm/memory-failure.c                   |    2 +-
>  mm/memory_hotplug.c                   |    6 +-
>  mm/page_alloc.c                       |  409 ++++++++++++++++++++++++++++----
>  mm/page_isolation.c                   |   15 +-
>  mm/vmstat.c                           |    3 +
>  35 files changed, 1790 insertions(+), 373 deletions(-)
>  create mode 100644 arch/arm/include/asm/dma-contiguous.h
>  create mode 100644 arch/x86/include/asm/dma-contiguous.h
>  create mode 100644 drivers/base/dma-contiguous.c
>  create mode 100644 include/asm-generic/dma-contiguous.h
>  create mode 100644 include/linux/dma-contiguous.h
>
> --
> 1.7.1.569.g6f426

Thanks
barry

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2012-02-29  9:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-22 16:48 Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 01/16] mm: page_alloc: remove trailing whitespace Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 02/16] mm: compaction: introduce isolate_migratepages_range() Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 03/16] mm: compaction: introduce map_pages() Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 04/16] mm: compaction: introduce isolate_freepages_range() Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 05/16] mm: compaction: export some of the functions Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 06/16] mm: page_alloc: introduce alloc_contig_range() Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 07/16] mm: page_alloc: change fallbacks array handling Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 08/16] mm: mmzone: MIGRATE_CMA migration type added Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 09/16] mm: page_isolation: MIGRATE_CMA isolation functions added Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 10/16] mm: Serialize access to min_free_kbytes Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 11/16] mm: extract reclaim code from __alloc_pages_direct_reclaim() Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 12/16] mm: trigger page reclaim in alloc_contig_range() to stabilise watermarks Marek Szyprowski
2012-02-29  9:48   ` [Linaro-mm-sig] " Barry Song
2012-03-08 21:25   ` Sandeep Patil
2012-02-22 16:48 ` [PATCHv23 13/16] drivers: add Contiguous Memory Allocator Marek Szyprowski
2012-02-29  9:53   ` [Linaro-mm-sig] " Barry Song
2012-02-22 16:48 ` [PATCHv23 14/16] X86: integrate CMA with DMA-mapping subsystem Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 15/16] ARM: " Marek Szyprowski
2012-02-22 16:48 ` [PATCHv23 16/16] ARM: Samsung: use CMA for 2 memory banks for s5p-mfc device Marek Szyprowski
2012-02-29  9:35 ` Barry Song [this message]
2012-02-29 11:43   ` [Linaro-mm-sig] [PATCHv23 00/16] Contiguous Memory Allocator Michal Nazarewicz
2012-02-29 13:34     ` Barry Song
2012-02-29 13:36       ` Michal Nazarewicz
2012-02-29 13:43         ` Barry Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGsJ_4wgVcVjtAa6Qpki=8jSON7MfwJ8yumJ1YXE5p8L3PqUzw@mail.gmail.com' \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=corbet@lwn.net \
    --cc=dave@linux.vnet.ibm.com \
    --cc=dwalker@codeaurora.org \
    --cc=jesse.barker@linaro.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=mel@csn.ul.ie \
    --cc=mina86@mina86.com \
    --cc=ohad@wizery.com \
    --cc=rob.clark@linaro.org \
    --cc=workgroup.linux@csr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox