Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp262639lqm; Tue, 30 Apr 2024 22:10:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUL9QkEypst0umArrRRZ0Ps3/clq8nNQh5N2a+D45kyXo0XK8rZhiJUBD4TF3cIXaqvb7+lkDDwnTa/RbXHuPifX7z0KQ/2NlJEImytsA== X-Google-Smtp-Source: AGHT+IFg3h8leSo6rBDoiW1I2lPKTImEHM2x6WRwBivlIQWZ3j08ggOim/+XCiM46z685M2gDycb X-Received: by 2002:a05:6214:2507:b0:699:2527:9843 with SMTP id gf7-20020a056214250700b0069925279843mr3236933qvb.5.1714540253491; Tue, 30 Apr 2024 22:10:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714540253; cv=pass; d=google.com; s=arc-20160816; b=DR86paq1KEBS8RAHadcapJMyhBBCLX0DwEsrd5ddZb86EvXr4MgWLIGmtE8WPT7hWE ygtXVOEzPWv1UZuSYsltnaZZelOKbyeUlfishoubpYXSI29LYHsNVnXiifEqJSWxeGjl RO7ihDnIJNCcw6Hln8ivAlP7gV5X1gOW49kpl5lwsX15MvBtmLHQ5R1IV7lAC0Js5I+1 OhnRv2fPUVcD34NhgWdCvVGv/+KTjRhsB51JnwDMG1kloN4ObEZ1ZAatHTkiMkwqXslu fx9OxXLN3stAequzqZ37DEu255MSI0y95bxYoMo7+Em3gtlhoO7TZz6dLCO79wtX4F8P KVWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ZJnNK/MnEG9qMPL1FuqG5TKlT7E9DMRIpWhLMGe3XgM=; fh=JhWS26qrIv7VmrVO6r9l8K5MO4D+tXz8MMJO1P5Y7wg=; b=ofmpZvuPb3tmRCRwrxVYn1EOL3JTvSk6uTukBJnT3NiffJeQfgHY1BdQx4lLhU8S6f 5Nc/7FSYtAaaIzWeLkqhbH9jBvovDmvijIy8UsUyLEISY8+BAELCdS5Ep+NUtjR/iORP FT67rwefkThFTxv+bgXQpmUD39Oq4sm7uPYdj/zfxhHwo8VOAgcfsMwQfXzxM7G/pM7F 8Huyn1yRTp6TLIH5mslEYWeqkxqN0ag6fKgIZxhOmhS6HWoYtYs0se5XuFdtEw5Era/C PmZFfNo9J9qS6FOlHf1y9igOQQD6yoKL1iWzqeNhmqm8iLXe2Hr4MPYMnxmAVKUsi0uB HBzQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=NQxw3065; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-164936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164936-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id fo11-20020ad45f0b000000b00696ae57d087si30659923qvb.338.2024.04.30.22.10.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 22:10:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=NQxw3065; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-164936-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164936-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 337831C220A3 for ; Wed, 1 May 2024 05:10:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6AAA433D4; Wed, 1 May 2024 05:10:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="NQxw3065" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C20C91D68F; Wed, 1 May 2024 05:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714540246; cv=none; b=fqCOUuyFsqrhsM+kCqn+bYnQMDqADFE9LXUB9yo/8uzI2TytCTNibYeA3YHeyG3ld9SmtMa3tJZIByFm/kpqZH59nUPb8WoFtqU0WgTXx/ZROZboVBTBt/g5LlzyHKveCWCbFexTHFLCl7VwQkMxe5BvRwg7O4RERI2GhyNQDrA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714540246; c=relaxed/simple; bh=Bv88zmq3RPg/NvCA06fPuh97Gm9jkIZqCFlN99SZZdA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WwkL/aGCJTfoohRV6x71mOHizkyhoAssKS2+0cGNZgWHY0kyrxyoZvrAf0x0fBOFlQBWn5GTC+p5deodWlc6fn1iJ7OIIfhJQg1qFzuqw5J/FO3ea0Fd/QFj5OwndNUSrTS8rE3NtviG7uHDfADGnLF/DiYyO+2CEzRCKQpPMks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=NQxw3065; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=ZJnNK/MnEG9qMPL1FuqG5TKlT7E9DMRIpWhLMGe3XgM=; b=NQxw3065lxg4fQI2HFvlgUpYti lzlbrrDiKLvY44vYon3tjNHAtrlrrycj0S6cn1buHgeE4YA6+aVO7FE0Ty02nWJz6ELsuqaPiUlJY Ax5iMe6n526pPWRYCruonTVf47E4t/VzvGghGANyb4GLc4niPnZiqYwsaWpaTSLHGzrfr4I37FIaP uLsA5ovN1PODX9uwAnu/aMBo8ng7dB0VNJeoh2w10EavNCqcKRgCdH6ayCJuoXUhbXyDjkoEkGMcF IH05qXIOpZdukF0sps1voGXIzh0IFAKC8vBZNFGvDSVa2RuZDSCM45D3QRvYucEPD3PfUWnJHbiIN 9bbH2Qgw==; Received: from hch by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1s22Et-00000008apr-1VQ5; Wed, 01 May 2024 05:10:43 +0000 Date: Tue, 30 Apr 2024 22:10:43 -0700 From: Christoph Hellwig To: John Hubbard Cc: Andrew Morton , Jason Gunthorpe , LKML , linux-rdma@vger.kernel.org, linux-mm@kvack.org, Mike Marciniszyn , Leon Romanovsky , Artemy Kovalyov , Michael Guralnik , Alistair Popple , Pak Markthub Subject: Re: [RFC] RDMA/umem: pin_user_pages*() can temporarily fail due to migration glitches Message-ID: References: <20240501003117.257735-1-jhubbard@nvidia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240501003117.257735-1-jhubbard@nvidia.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html > + pinned = -ENOMEM; > + int attempts = 0; > + /* > + * pin_user_pages_fast() can return -EAGAIN, due to falling back > + * to gup-slow and then failing to migrate pages out of > + * ZONE_MOVABLE due to a transient elevated page refcount. > + * > + * One retry is enough to avoid this problem, so far, but let's > + * use a slightly higher retry count just in case even larger > + * systems have a longer-lasting transient refcount problem. > + * > + */ > + static const int MAX_ATTEMPTS = 3; > + > + while (pinned == -EAGAIN && attempts < MAX_ATTEMPTS) { > + pinned = pin_user_pages_fast(cur_base, > + min_t(unsigned long, > + npages, PAGE_SIZE / > + sizeof(struct page *)), > + gup_flags, page_list); > ret = pinned; > - goto umem_release; > + attempts++; > + > + if (pinned == -EAGAIN) > + continue; > } > + if (pinned < 0) > + goto umem_release; This doesn't make sense. IFF a blind retry is all that is needed it should be done in the core functionality. I fear it's not that easy, though.