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=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 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 778FECA9EC4 for ; Tue, 29 Oct 2019 13:59:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 29A0920862 for ; Tue, 29 Oct 2019 13:59:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="TOjiKaf4" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29A0920862 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B114F6B0007; Tue, 29 Oct 2019 09:59:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC1636B0008; Tue, 29 Oct 2019 09:59:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AFD56B000A; Tue, 29 Oct 2019 09:59:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0083.hostedemail.com [216.40.44.83]) by kanga.kvack.org (Postfix) with ESMTP id 752546B0007 for ; Tue, 29 Oct 2019 09:59:40 -0400 (EDT) Received: from smtpin30.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 0B6388249980 for ; Tue, 29 Oct 2019 13:59:40 +0000 (UTC) X-FDA: 76096980120.30.look65_5457a8612e34e X-HE-Tag: look65_5457a8612e34e X-Filterd-Recvd-Size: 6763 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Tue, 29 Oct 2019 13:59:39 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id g21so12260349qkm.11 for ; Tue, 29 Oct 2019 06:59:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8jOH6aTboFzH2FE5ebDVzGbVS8tkTfz/e6O//bI0tkY=; b=TOjiKaf4drtV5ldH8zR3DdZRftx4pfyMK7aX+WxF+hP7GAklHNLQJLB3u6THZAuUwq 2J8U2Z8jfa4RHHqJi86VA8XDEEftIwINME4Xcqo7Lwf5TfQ/5CHndbgRjMZBi7ltmTD/ 9/OIdOP+IKZBXBOnw95rEg1RRCcplq0VveMXmbgEcrW0nIfOMVnpZGUZJC/dcmVtrcLp GnztoS4X7Cig0PpARFdiBQAFwuPsNE3oq28XslCe7YAiytEpFuhH3cYXFITze125lBn3 w8SiavcWCCYZB5EGHirP4nTYv97GbqlF/YYAtwW9ZFYvfLIJ06XZktP4ccL77Rn8KbAv rdng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8jOH6aTboFzH2FE5ebDVzGbVS8tkTfz/e6O//bI0tkY=; b=qQUr3BIli52Dlwdpd74BcMIkfhbMeM/ifswmvbcrJE10drXG1TW4dEIllgnc9N1ms1 TvX5t/KQr4NvInjwLOSzME6mOQTcjNFAaxxGaSpfXh0vLwOcY0V+Ss0YJictrp6WuOtV xISVY6HVcQo9DkVoylmpjA8gL0kXKPabGOBuIc8sGRgaenNZ+omEA6kY1MPyQYo261+D 18EwX1rz6u4puFY4mWKtNITZAhEV28yT6JWhdY24N9havYA57wbdQfDCfvhvDtltBtRa f0yG+J6wdS4SfI3zf3MKxFggobx56DEKJscfQ94sOpgoxAlAlMo8jdI2Ru26W3JNBguC Qm0w== X-Gm-Message-State: APjAAAXgaM0fm1oZYBOKqfIx4le/9n5WsdKS76+KZAgXntFB0jEjPlpq r6ObBQ/zT9zdZRVDmDNWd0GVQg== X-Google-Smtp-Source: APXvYqw2t3qlIvqK+Izwy8tw608BKfVw2jgQ/Y0rREEshgcaboVymXi/nbliXAwFtIZ8GNBEqxuwOw== X-Received: by 2002:a05:620a:8cb:: with SMTP id z11mr15146993qkz.72.1572357577964; Tue, 29 Oct 2019 06:59:37 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-162-113-180.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.180]) by smtp.gmail.com with ESMTPSA id p188sm7446102qkb.33.2019.10.29.06.59.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Oct 2019 06:59:36 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1iPS24-0005x3-D2; Tue, 29 Oct 2019 10:59:36 -0300 Date: Tue, 29 Oct 2019 10:59:36 -0300 From: Jason Gunthorpe To: "Koenig, Christian" Cc: "linux-mm@kvack.org" , Jerome Glisse , Ralph Campbell , John Hubbard , "Kuehling, Felix" , "linux-rdma@vger.kernel.org" , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , "Deucher, Alexander" , Ben Skeggs , Boris Ostrovsky , "Zhou, David(ChunMing)" , Dennis Dalessandro , Juergen Gross , Mike Marciniszyn , Oleksandr Andrushchenko , Petr Cvek , Stefano Stabellini , "nouveau@lists.freedesktop.org" , "xen-devel@lists.xenproject.org" , Christoph Hellwig Subject: Re: [PATCH v2 13/15] drm/amdgpu: Use mmu_range_insert instead of hmm_mirror Message-ID: <20191029135936.GD6128@ziepe.ca> References: <20191028201032.6352-1-jgg@ziepe.ca> <20191028201032.6352-14-jgg@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) 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 Tue, Oct 29, 2019 at 07:51:30AM +0000, Koenig, Christian wrote: > > +static bool amdgpu_mn_invalidate_gfx(struct mmu_range_notifier *mrn, > > + const struct mmu_notifier_range *range) > > { > > - struct amdgpu_bo *bo; > > + struct amdgpu_bo *bo = container_of(mrn, struct amdgpu_bo, notifier); > > + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); > > long r; > > > > - list_for_each_entry(bo, &node->bos, mn_list) { > > - > > - if (!amdgpu_ttm_tt_affect_userptr(bo->tbo.ttm, start, end)) > > - continue; > > - > > - r = dma_resv_wait_timeout_rcu(bo->tbo.base.resv, > > - true, false, MAX_SCHEDULE_TIMEOUT); > > - if (r <= 0) > > - DRM_ERROR("(%ld) failed to wait for user bo\n", r); > > - } > > + /* FIXME: Is this necessary? */ > > Most likely not. > > Christian. > > > + if (!amdgpu_ttm_tt_affect_userptr(bo->tbo.ttm, range->start, > > + range->end)) > > + return true; So is the bo->tbo.mem.num_pages == bo->tbo.ttm.num_pages always? And userptr can't be zero here, or at least it doesn't matter if it is? > > +static bool amdgpu_mn_invalidate_hsa(struct mmu_range_notifier *mrn, > > + const struct mmu_notifier_range *range) > > { > > - struct amdgpu_mn *amn = container_of(mirror, struct amdgpu_mn, mirror); > > - unsigned long start = update->start; > > - unsigned long end = update->end; > > - bool blockable = mmu_notifier_range_blockable(update); > > - struct interval_tree_node *it; > > - > > - /* notification is exclusive, but interval is inclusive */ > > - end -= 1; > > - > > - /* TODO we should be able to split locking for interval tree and > > - * amdgpu_mn_invalidate_node > > - */ > > - if (amdgpu_mn_read_lock(amn, blockable)) > > - return -EAGAIN; > > - > > - it = interval_tree_iter_first(&amn->objects, start, end); > > - while (it) { > > - struct amdgpu_mn_node *node; > > - > > - if (!blockable) { > > - amdgpu_mn_read_unlock(amn); > > - return -EAGAIN; > > - } > > + struct amdgpu_bo *bo = container_of(mrn, struct amdgpu_bo, notifier); > > + struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev); > > > > - node = container_of(it, struct amdgpu_mn_node, it); > > - it = interval_tree_iter_next(it, start, end); > > + /* FIXME: Is this necessary? */ > > + if (!amdgpu_ttm_tt_affect_userptr(bo->tbo.ttm, range->start, > > + range->end)) > > + return true; > > > > - amdgpu_mn_invalidate_node(node, start, end); > > - } This one too right? Jason