The following series implements the updated api for wait/wound mutex locks.
The documentation and api should be complete, the implementation may not be
final. There is no support for -rt yet, and TASK_DEADLOCK handling is missing
too. However I believe that this is an implementation detail, and that the
interface for users of the api will not behave differently.
ww_acquire_ctx has been added, and a whole lot of api abuses are now correctly
detected because of the extra state carried in ww_acquire_ctx if debugging is
enabled.
---
Maarten Lankhorst (3):
arch: make __mutex_fastpath_lock_retval return whether fastpath succeeded or not.
mutex: add support for wound/wait style locks, v3
mutex: Add ww tests to lib/locking-selftest.c. v3
Documentation/ww-mutex-design.txt | 322 +++++++++++++++++++++++++
arch/ia64/include/asm/mutex.h | 10 -
arch/powerpc/include/asm/mutex.h | 10 -
arch/sh/include/asm/mutex-llsc.h | 4
arch/x86/include/asm/mutex_32.h | 11 -
arch/x86/include/asm/mutex_64.h | 11 -
include/asm-generic/mutex-dec.h | 10 -
include/asm-generic/mutex-null.h | 2
include/asm-generic/mutex-xchg.h | 10 -
include/linux/mutex-debug.h | 1
include/linux/mutex.h | 257 ++++++++++++++++++++
kernel/mutex.c | 473 ++++++++++++++++++++++++++++++++++---
lib/debug_locks.c | 2
lib/locking-selftest.c | 439 +++++++++++++++++++++++++++++++++-
14 files changed, 1469 insertions(+), 93 deletions(-)
create mode 100644 Documentation/ww-mutex-design.txt
--
Signature
Hello,
Contiguous Memory Allocator is very sensitive about migration failures
of the individual pages. A single page, which causes permanent migration
failure can break large conitguous allocations and cause the failure of
a multimedia device driver.
One of the known issues with migration of CMA pages are the problems of
migrating the anonymous user pages, for which the others called
get_user_pages(). This takes a reference to the given user pages to let
kernel to operate directly on the page content. This is usually used for
preventing swaping out the page contents and doing direct DMA to/from
userspace.
To solving this issue requires preventing locking of the pages, which
are placed in CMA regions, for a long time. Our idea is to migrate
anonymous page content before locking the page in get_user_pages(). This
cannot be done automatically, as get_user_pages() interface is used very
often for various operations, which usually last for a short period of
time (like for example exec syscall). We have added a new flag
indicating that the given get_user_space() call will grab pages for a
long time, thus it is suitable to use the migration workaround in such
cases.
The proposed extensions is used by V4L2/VideoBuf2
(drivers/media/v4l2-core/videobuf2-dma-contig.c), but that is not the
only place which might benefit from it, like any driver which use DMA to
userspace with get_user_pages(). This one is provided to demonstrate the
use case.
I would like to hear some comments on the presented approach. What do
you think about it? Is there a chance to get such workaround merged at
some point to mainline?
Best regards
Marek Szyprowski
Samsung Poland R&D Center
Patch summary:
Marek Szyprowski (5):
mm: introduce migrate_replace_page() for migrating page to the given
target
mm: get_user_pages: use static inline
mm: get_user_pages: use NON-MOVABLE pages when FOLL_DURABLE flag is
set
mm: get_user_pages: migrate out CMA pages when FOLL_DURABLE flag is
set
media: vb2: use FOLL_DURABLE and __get_user_pages() to avoid CMA
migration issues
drivers/media/v4l2-core/videobuf2-dma-contig.c | 8 +-
include/linux/highmem.h | 12 ++-
include/linux/migrate.h | 5 +
include/linux/mm.h | 76 ++++++++++++-
mm/internal.h | 12 +++
mm/memory.c | 136 +++++++++++-------------
mm/migrate.c | 59 ++++++++++
7 files changed, 225 insertions(+), 83 deletions(-)
--
1.7.9.5
On Wed, May 1, 2013 at 6:30 AM, Dave Airlie <airlied(a)gmail.com> wrote:
> Since we ask the dmabuf owner to map the dma-buf into our device
> address space, but for udl at present that is the CPU address space,
> since we don't DMA directly from the mapped buffer.
>
> However if we don't set a dma mask on the usb device, the mapping
> ends up using swiotlb on machines that have it enabled, which
> is less than desireable.
>
> Signed-off-by: Dave Airlie <airlied(a)redhat.com>
Fyi for everyone else who was not on irc when Dave&I discussed this:
This really shouldn't be required and I think the real issue is that
udl creates a dma_buf attachement (which is needed for device dma
only), but only really wants to do cpu access through vmap/kmap. So
not attached the device should be good enough. Cc'ing a few more lists
for better fyi ;-)
-Daniel
> ---
> drivers/gpu/drm/udl/udl_main.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
> index 0ce2d71..6770e1b 100644
> --- a/drivers/gpu/drm/udl/udl_main.c
> +++ b/drivers/gpu/drm/udl/udl_main.c
> @@ -293,6 +293,7 @@ int udl_driver_load(struct drm_device *dev, unsigned long flags)
> udl->ddev = dev;
> dev->dev_private = udl;
>
> + dma_set_mask(dev->dev, DMA_BIT_MASK(64));
> if (!udl_parse_vendor_descriptor(dev, dev->usbdev)) {
> DRM_ERROR("firmware not recognized. Assume incompatible device\n");
> goto err;
> --
> 1.8.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel(a)lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Hi all,
I've been looking at a better way to do custom dma allocation algorithms
in a similar style to Ion heaps. Most drivers/clients have come up with
a series of semi-standard ways to get memory (CMA, memblock_reserve,
discontiguous pages etc.) . As these allocation schemes get more and
more complex, there needs to be a since place where all clients (Ion
based driver vs. DRM driver vs. ???) can independently take advantage
of any optimizations and call a single API for the backing allocations.
The dma_map_ops take care of almost everything needed for abstraction
but the question is where should new allocation algorithms be located?
Most of the work has been added to either arm/mm/dma-mapping.c or
dma-contiguous.c . My current thought:
1) split out the dma_map_ops currently in dma-mapping.c into separate
files (dma-mapping-common.c, dma-mapping-iommu.c)
2) Extend dma-contiguous.c to support memblock_reserve memory
3) Place additional algorithms in either arch/arm/mm or
drivers/base/dma-alloc/ as appropriate to the code. This is the part
where I'm most unsure about the direction.
I don't have anything written yet but I plan to draft some patches
assuming the proposed approach sounds reasonable and no one else has
started on something similar already.
Thoughts? Opinions?
Thanks,
Laura
--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
hosted by The Linux Foundation
Hi Linus,
The 3.10 pull request for dma-buf framework updates: small one, could
you please pull?
Thanks and best regards,
~Sumit.
The following changes since commit 5f56886521d6ddd3648777fae44d82382dd8c87f:
Merge branch 'akpm' (incoming from Andrew) (2013-04-30 17:37:43 -0700)
are available in the git repository at:
git://git.linaro.org/people/sumitsemwal/linux-dma-buf.git
tags/tag-for-linus-3.10
for you to fetch changes up to b89e35636bc75b72d15a1af6d49798802aff77d5:
dma-buf: Add debugfs support (2013-05-01 16:36:22 +0530)
----------------------------------------------------------------
3.10 dma-buf updates
Added debugfs support to dma-buf.
----------------------------------------------------------------
Sumit Semwal (2):
dma-buf: replace dma_buf_export() with dma_buf_export_named()
dma-buf: Add debugfs support
Documentation/dma-buf-sharing.txt | 13 ++-
drivers/base/dma-buf.c | 169 +++++++++++++++++++++++++++++++++++++-
include/linux/dma-buf.h | 16 +++-
3 files changed, 189 insertions(+), 9 deletions(-)