From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8A490C433DF for ; Mon, 12 Oct 2020 13:49:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C6012206D9 for ; Mon, 12 Oct 2020 13:49:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="OxcKeNhv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6012206D9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 03E94940007; Mon, 12 Oct 2020 09:49:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F30AC900002; Mon, 12 Oct 2020 09:49:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E20C0940007; Mon, 12 Oct 2020 09:49:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id AF1E9900002 for ; Mon, 12 Oct 2020 09:49:20 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4E2D81EF1 for ; Mon, 12 Oct 2020 13:49:20 +0000 (UTC) X-FDA: 77363405280.11.cough42_3413904271fb Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin11.hostedemail.com (Postfix) with ESMTP id 15552180F8B86 for ; Mon, 12 Oct 2020 13:49:20 +0000 (UTC) X-HE-Tag: cough42_3413904271fb X-Filterd-Recvd-Size: 4773 Received: from mail-ot1-f65.google.com (mail-ot1-f65.google.com [209.85.210.65]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Mon, 12 Oct 2020 13:49:19 +0000 (UTC) Received: by mail-ot1-f65.google.com with SMTP id l4so15862630ota.7 for ; Mon, 12 Oct 2020 06:49:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=8X09Z4RduZw54E7UULyfcMVsq59sUX38yzJavXEvAuQ=; b=OxcKeNhvQoR0L8nxbCn1cXzOLqpqQBDfywbnUKwin8fP1jeNNo8TXGjdlV3i/RFefc kiDn5u8kWGFx2VxB985ageHcqSHKlzq4zLw3IXCA9ks8vIzNebZc3IQZx/DZrDgmJSXd NsUKEksWwYQT7XMaHoiEwCdO/DkttVP0ejuaI= 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; bh=8X09Z4RduZw54E7UULyfcMVsq59sUX38yzJavXEvAuQ=; b=rgyHqyg7ViT5trJxRFDKmxcBwnrI3RaH+us52JV0aq8cDHY0G65NIQqtPk/sNFfPeV cU1UA7Hn+p4QoVDmOH/+2XaxKD1dTYz8ZqnTWNeolV94UMTuErX0cZ9byk+H1EjWNjfp rnFT21XkyAIPavqi3fYy4FsY7MFgEEVYSNkJ6C8WoJCJZUD0TGUfg1IRShzy3aAXTuqo hYjw+150bgAWRQWjIU88odsBQiE5zVHWsPrCLnonrc5IPR7q3fSfPe2O0QwjW5RcEFWk opr4cfuoRVD9xlvjiDA/ZP/wr0H5EqXXiF74YFK9rpiw426APRkz9zQXzL+tZdh97rrS YQkg== X-Gm-Message-State: AOAM532Ht8LoxTBMbDy2ZvpKew8DzcppmaWCAzQOEd4DFAmn2m/GVEST IyJdJ+IV8Xposma5CucSL/0x5wQ6RTooTEcg4pOtZg== X-Google-Smtp-Source: ABdhPJx2SbzoAtarumY1qTqnmUTVH9IgcM13EmZUSL9fGwCe3viWjRc3PXrzmY6z+PXG92wLIZXLR8i7oO5kJrgMePc= X-Received: by 2002:a05:6830:8b:: with SMTP id a11mr7008058oto.303.1602510558346; Mon, 12 Oct 2020 06:49:18 -0700 (PDT) MIME-Version: 1.0 References: <20201009075934.3509076-1-daniel.vetter@ffwll.ch> <20201009075934.3509076-10-daniel.vetter@ffwll.ch> <20201009123421.67a80d72@coco.lan> <20201009122111.GN5177@ziepe.ca> <20201009143723.45609bfb@coco.lan> <20201009124850.GP5177@ziepe.ca> In-Reply-To: From: Daniel Vetter Date: Mon, 12 Oct 2020 15:49:07 +0200 Message-ID: Subject: Re: [PATCH v2 09/17] mm: Add unsafe_follow_pfn To: Marek Szyprowski Cc: Jason Gunthorpe , Mauro Carvalho Chehab , linux-s390 , linux-samsung-soc , Jan Kara , Kees Cook , KVM list , LKML , DRI Development , Linux MM , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , John Hubbard , Daniel Vetter , Dan Williams , Linus Torvalds , Andrew Morton , Linux ARM , "open list:DMA BUFFER SHARING FRAMEWORK" Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 12, 2020 at 12:47 PM Marek Szyprowski wrote: > > Hi Jason, > > On 09.10.2020 14:48, Jason Gunthorpe wrote: > > On Fri, Oct 09, 2020 at 02:37:23PM +0200, Mauro Carvalho Chehab wrote: > > > >> I'm not a mm/ expert, but, from what I understood from Daniel's patch > >> description is that this is unsafe *only if* __GFP_MOVABLE is used. > > No, it is unconditionally unsafe. The CMA movable mappings are > > specific VMAs that will have bad issues here, but there are other > > types too. > > I'm trying to follow this thread, but I really wonder what do you mean > by CMA movable mappings? If a buffer has been allocated from CMA and > used for DMA, it won't be moved in the memory. It will stay at the same > physical memory address all the time until freed by the owner. It just a > matter of proper usage count tracking to delay freeing if it is still > used somewhere. Yup. The problem is that this usage count tracking doesn't exist. And drivers could at least in theory treat CMA like vram and swap buffers in&out of it, so just refcounting the userspace vma isn't enough. In practice, right now, it might be enough for CMA drivers though (but there's more that's possible here). -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch