Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2814808imb; Mon, 4 Mar 2019 15:11:43 -0800 (PST) X-Google-Smtp-Source: APXvYqw1Ymfbxqd1kiGlSc9N8ZYhmS7rKm06FKkcfZ1uQwjGuNuZI32rWh+YqwMAzWUFBdKZnz8D X-Received: by 2002:a17:902:a981:: with SMTP id bh1mr5448212plb.88.1551741103903; Mon, 04 Mar 2019 15:11:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551741103; cv=none; d=google.com; s=arc-20160816; b=DvY1EOnYLoIHQDkXObRecPyZ9ZmS4ygpJfiwmPizM1DIJZaEwdm94J/wkclP5dY0jp 6mnK1QwYmi22afL/2h56wuOkq+VxmLkxFsOPk334cVpYBeB31jOJNhiYh2xvsOABWuab BwO86Bw2tq3god/3fp/SqnJOtpsikx34+owuNrN8y8METwbGCuWsuZcYu4P0nhf6CQu4 SRNEk7iSZvlob22BOZfInFplw74Zs4ciI3adnoiSK8pb1G3N9469nIzSSBuPDBwUHzKe Alsgrg9aHNC22sNNRqYUNk8dzOiwoZZJWc3NAQcm9MM7D8pSiDGwhPKjnZDNjFVxKu7I OUzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=AcOE5zfOZlN0A/nrsbhxxR+K8ncz9Jke8a4dU/jfTkI=; b=GF9FlhRYaWxfP4y2Ju4QTX09JZZBm+if6qCgTnNsSTpXUoO4hlQLxazGMwBkyvU5HY P/6NCN5AZ5ubNIbAoFReyCggU8fziQilvv9Y0FpwfRBU7BBNqoi1l2lp+AP5ge6FmiTf fjdQfdoollZ6rJDh6Tp/ZXC5RnX/zMV3kH/OzG3bbHqUTH4z+bxZOwd/XBHmu4Uk/0jx A3u/kgJQjSvEh9ayDfhW7WW/gvXpxPit56yjhRZMhaQBbk9WQbFALSHE6hT0pseeWRbu 40iiR0fQsWjBr2kW8aiprxTnt+9lxUW3aDqIT5YJV4oTc8YbQoKbQ4LzVV9C5NZWqdJD Mq9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=M4EdluFM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 136si6597262pfu.221.2019.03.04.15.11.28; Mon, 04 Mar 2019 15:11:43 -0800 (PST) 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=@nvidia.com header.s=n1 header.b=M4EdluFM; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726412AbfCDXLH (ORCPT + 99 others); Mon, 4 Mar 2019 18:11:07 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:5876 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbfCDXLG (ORCPT ); Mon, 4 Mar 2019 18:11:06 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 04 Mar 2019 15:11:05 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 04 Mar 2019 15:11:06 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 04 Mar 2019 15:11:06 -0800 Received: from [10.110.48.28] (172.20.13.39) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 4 Mar 2019 23:11:05 +0000 Subject: Re: [PATCH v2] RDMA/umem: minor bug fix and cleanup in error handling paths To: Ira Weiny , Artemy Kovalyov CC: "john.hubbard@gmail.com" , "linux-mm@kvack.org" , Andrew Morton , LKML , Jason Gunthorpe , Doug Ledford , "linux-rdma@vger.kernel.org" References: <20190302032726.11769-2-jhubbard@nvidia.com> <20190302202435.31889-1-jhubbard@nvidia.com> <20190302194402.GA24732@iweiny-DESK2.sc.intel.com> <2404c962-8f6d-1f6d-0055-eb82864ca7fc@mellanox.com> <20190303165550.GB27123@iweiny-DESK2.sc.intel.com> From: John Hubbard X-Nvconfidentiality: public Message-ID: Date: Mon, 4 Mar 2019 15:11:05 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190303165550.GB27123@iweiny-DESK2.sc.intel.com> X-Originating-IP: [172.20.13.39] X-ClientProxiedBy: HQMAIL106.nvidia.com (172.18.146.12) To HQMAIL101.nvidia.com (172.20.187.10) Content-Type: text/plain; charset="utf-8" Content-Language: en-US-large Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1551741065; bh=AcOE5zfOZlN0A/nrsbhxxR+K8ncz9Jke8a4dU/jfTkI=; h=X-PGP-Universal:Subject:To:CC:References:From:X-Nvconfidentiality: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=M4EdluFMzpFbdlvmJgg9sDSyl9ybTTuXn2Ye4Uo4+uio+hXE1LugAMTN9FJeMixOh xM4ZkJG6F+lws7n4aKQ87vfBeTbGrR4P5kVTqpVw3SeOIiHyPis4GpqaPWq9vI9C5F WX6vr4ecIWxnmRYksYumBMASeqgSajxi1jb6NIos2qZL0mp73McyUDW80MWsV9e6HQ ZL+/ub+nAfcqO4AwPcC60pc4dJI4wAHUkfa6tO6io8hqvFYy21TMt+FrgL7TKcHsua eT57n4DnctCLzUBjgeNA5sZY02hizFRl7N+JXl7F8DkHU224BBfpm40nuO22362lD/ 2XtwsbR7rlqbQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/19 8:55 AM, Ira Weiny wrote: > On Sun, Mar 03, 2019 at 11:52:41AM +0200, Artemy Kovalyov wrote: >> >> >> On 02/03/2019 21:44, Ira Weiny wrote: >>> >>> On Sat, Mar 02, 2019 at 12:24:35PM -0800, john.hubbard@gmail.com wrote: >>>> From: John Hubbard >>>> >>>> ... >>>> 3. Dead code removal: the check for (user_virt & ~page_mask) >>>> is checking for a condition that can never happen, >>>> because earlier: >>>> >>>> user_virt = user_virt & page_mask; >>>> >>>> ...so, remove that entire phrase. >>>> >>>> bcnt -= min_t(size_t, npages << PAGE_SHIFT, bcnt); >>>> mutex_lock(&umem_odp->umem_mutex); >>>> for (j = 0; j < npages; j++, user_virt += PAGE_SIZE) { >>>> - if (user_virt & ~page_mask) { >>>> - p += PAGE_SIZE; >>>> - if (page_to_phys(local_page_list[j]) != p) { >>>> - ret = -EFAULT; >>>> - break; >>>> - } >>>> - put_page(local_page_list[j]); >>>> - continue; >>>> - } >>>> - >>> >>> I think this is trying to account for compound pages. (ie page_mask could >>> represent more than PAGE_SIZE which is what user_virt is being incrimented by.) >>> But putting the page in that case seems to be the wrong thing to do? >>> >>> Yes this was added by Artemy[1] now cc'ed. >> >> Right, this is for huge pages, please keep it. >> put_page() needed to decrement refcount of the head page. > > You mean decrement the refcount of the _non_-head pages? > > Ira > Actually, I'm sure Artemy means head page, because put_page() always operates on the head page. And this reminds me that I have a problem to solve nearby: get_user_pages on huge pages increments the page->_refcount *for each tail page* as well. That's a minor problem for my put_user_page() patchset, because my approach so far assumed that I could just change us over to: get_user_page(): increments page->_refcount by a large amount (1024) put_user_page(): decrements page->_refcount by a large amount (1024) ...and just stop doing the odd (to me) technique of incrementing once for each tail page. I cannot see any reason why that's actually required, as opposed to just "raise the page->_refcount enough to avoid losing the head page too soon". However, it may be tricky to do this in one pass. Probably at first, I'll have to do this horrible thing approach: get_user_page(): increments page->_refcount by a large amount (1024) put_user_page(): decrements page->_refcount by a large amount (1024) MULTIPLIED by the number of tail pages. argghhh that's ugly. thanks, -- John Hubbard NVIDIA