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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 C42A0C433E2 for ; Mon, 14 Sep 2020 21:55:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5EF7C208DB for ; Mon, 14 Sep 2020 21:55:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="MqTu9NEE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EF7C208DB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A526D900008; Mon, 14 Sep 2020 17:55:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A01628E0001; Mon, 14 Sep 2020 17:55:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 900CE900008; Mon, 14 Sep 2020 17:55:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0205.hostedemail.com [216.40.44.205]) by kanga.kvack.org (Postfix) with ESMTP id 784EC8E0001 for ; Mon, 14 Sep 2020 17:55:08 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3A454180AD81F for ; Mon, 14 Sep 2020 21:55:08 +0000 (UTC) X-FDA: 77263023096.16.leaf67_22037c12710c Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id 0B171100E6933 for ; Mon, 14 Sep 2020 21:55:08 +0000 (UTC) X-HE-Tag: leaf67_22037c12710c X-Filterd-Recvd-Size: 6303 Received: from mail29.static.mailgun.info (mail29.static.mailgun.info [104.130.122.29]) by imf25.hostedemail.com (Postfix) with ESMTP for ; Mon, 14 Sep 2020 21:55:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1600120507; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=McgfBzMTGCjtNIsTYVb4iriu19nAkMDbTGSM3XXPH4A=; b=MqTu9NEEz4InjIHB9giyXbS6Y1kvTEFmyxuZqbkzfKrRYLsMODQjNH3iddlZNEGLjrF8VMBL GxsWdc7bgtXcYJhYrx0OEcG/D7jGofwrwGLMSltyQpeDc0opB5HNYY8fYSr9g9XneZAIviGw Ty4jsobmGJb50INgHdvdsRqxo8s= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyIwY2Q3OCIsICJsaW51eC1tbUBrdmFjay5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n07.prod.us-west-2.postgun.com with SMTP id 5f5fe627698ee477d14ec6cd (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 14 Sep 2020 21:52:39 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C06B5C433F1; Mon, 14 Sep 2020 21:52:38 +0000 (UTC) Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cgoldswo) by smtp.codeaurora.org (Postfix) with ESMTPSA id D68DFC433CA; Mon, 14 Sep 2020 21:52:37 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Mon, 14 Sep 2020 14:52:37 -0700 From: Chris Goldsworthy To: David Hildenbrand Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, pratikp@codeaurora.org, pdaly@codeaurora.org, sudaraja@codeaurora.org, iamjoonsoo.kim@lge.com, linux-arm-msm-owner@vger.kernel.org, Vinayak Menon , linux-kernel-owner@vger.kernel.org Subject: Re: [PATCH v2] mm: cma: indefinitely retry allocations in cma_alloc In-Reply-To: <72ae0f361df527cf70946992e4ab1eb3@codeaurora.org> References: <06489716814387e7f147cf53d1b185a8@codeaurora.org> <1599851809-4342-1-git-send-email-cgoldswo@codeaurora.org> <010101747e998731-e49f209f-8232-4496-a9fc-2465334e70d7-000000@us-west-2.amazonses.com> <72ae0f361df527cf70946992e4ab1eb3@codeaurora.org> Message-ID: <57119844135c2b3ac5d075d077cd8c8e@codeaurora.org> X-Sender: cgoldswo@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 X-Rspamd-Queue-Id: 0B171100E6933 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000012, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2020-09-14 11:33, Chris Goldsworthy wrote: > On 2020-09-14 02:31, David Hildenbrand wrote: >> What about long-term pinnings? IIRC, that can happen easily e.g., with >> vfio (and I remember there is a way via vmsplice). >> >> Not convinced trying forever is a sane approach in the general case >> ... > > Hi David, > > I've botched the threading, so there are discussions with respect to > the previous patch-set that is missing on this thread, which I will > summarize below: > > V1: > [1] https://lkml.org/lkml/2020/8/5/1097 > [2] https://lkml.org/lkml/2020/8/6/1040 > [3] https://lkml.org/lkml/2020/8/11/893 > [4] https://lkml.org/lkml/2020/8/21/1490 > [5] https://lkml.org/lkml/2020/9/11/1072 > > [1] features version of the patch featured a finite number of retries, > which has been stable for our kernels. In [2], Andrew questioned > whether we could actually find a way of solving the problem on the > grounds that doing a finite number of retries doesn't actually fix the > problem (more importantly, in [4] Andrew indicated that he would > prefer not to merge the patch as it doesn't solve the issue). In [3], > I suggest one actual fix for this, which is to use > preempt_disable/enable() to prevent context switches from occurring > during the periods in copy_one_pte() and exit_mmap() (I forgot to > mention this case in the commit text) in which _refcount > _mapcount > for a page - you would also need to prevent interrupts from occurring > to if we were to fully prevent the issue from occurring. I think this > would be acceptable for the copy_one_pte() case, since there _refcount > > _mapcount for little time. For the exit_mmap() case, however, _refcount is greater than _mapcount whilst the page-tables are being torn down for a process - that could be too long for disabling preemption / interrupts. > > So, in [4], Andrew asks about two alternatives to see if they're > viable: (1) acquiring locks on the exit_mmap path and migration paths, > (2) retrying indefinitely. In [5], I discuss how using locks could > increase the time it takes to perform a CMA allocation, such that a > retry approach would avoid increased CMA allocation times. I'm also > uncertain about how the locking scheme could be implemented > effectively without introducing a new per-page lock that will be used > specifically to solve this issue, and I'm not sure this would be > accepted. > > We're fine with doing indefinite retries, on the grounds that if there > is some long-term pinning that occurs when alloc_contig_range returns > -EBUSY, that it should be debugged and fixed. Would it be possible to > make this infinite-retrying something that could be enabled or > disabled by a defconfig option? > > Thanks, > > Chris. Actually, if we were willing to have a defconfig option for enabling / disabling indefinite retries on the return of -EBUSY, would it be possibly to re-structure the patch to allow either (1) indefinite retrying, or (2) doing a fixed number of retires (as some people might want to tolerate CMA allocation failures in favor of making progress)? -- The Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project