Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp508331rwd; Wed, 17 May 2023 23:15:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5DVD1tjWxQxHupyG9Z+SQ4jp8PU/NMs5W+TwGc7IN50jblHBXxIcRPZ1BvbWSxnrzf9nQ6 X-Received: by 2002:a05:6a00:1991:b0:63f:18ae:1d5f with SMTP id d17-20020a056a00199100b0063f18ae1d5fmr3559032pfl.29.1684390506291; Wed, 17 May 2023 23:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684390506; cv=none; d=google.com; s=arc-20160816; b=UjWHk4TK6M777cXI+I79IO4mo5qedtLNMIyTn6UGRjrS/R1Z1EId6dNCoOSVc4Nr7p 9y94ux/DHeZOb3rgnaikHC57L4lOnImY9o09xEST4/f+cE3WeEnEIv+8DVhJYR/UfMPH 26v1yH4z39xqc0KKifSQC6FTbpHprbKB1/1izPkblnhLnqvi3RiApyIOKYFmP62378J+ NZLZQKwZFeEUmUjPQiKuzxqHg/sJUCp5HnWh0+M11eWoDUZnFZN+v5e8SPNnTVGPGS0+ G9w9EaFA6DpPJawCzZGqASWw1IRjz8XTMr3VwANDabj85EacO8V3wzU4EX44OMftDVKY Zhig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aSWZec/J0A95SxR8LujGdt3ORI4eM1n8G0sqzEOmKqg=; b=AHnDSBpNpXmfd8Qbq1RJQZVm7DUUGplziEZa1AIKaWu9VKOt87nneLwKawdxC2AR2Q y0IKe3VY0Of5zCHToIe225mL2AR/tWtLo9eBaKDtR/SF/RI2lQjgVIMxxxkVNsl3zfun LGcTu1QpqGGKSVh6OYwaUOQjw0fFKnjmjSqx7dg8O5AY5j5u3roSu1hjQysyiCICkV3h VwEa/7n3k5Y2XGYCxdBf9yAx5VoWs3NH209HqiOyuTmv2umCtGeXf5jASKU2+Nb3vRaA afw05OFld2DasSiR+w/7mLZd9woBhH8JXQtYSLeDbd33nt14DtOzmEWstQiYB5vyqZVQ TV/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvJmt+2i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m190-20020a633fc7000000b005303b739292si642909pga.702.2023.05.17.23.14.50; Wed, 17 May 2023 23:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VvJmt+2i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbjERGIe (ORCPT + 99 others); Thu, 18 May 2023 02:08:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjERGId (ORCPT ); Thu, 18 May 2023 02:08:33 -0400 Received: from mail-ua1-x930.google.com (mail-ua1-x930.google.com [IPv6:2607:f8b0:4864:20::930]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B3D2698 for ; Wed, 17 May 2023 23:08:31 -0700 (PDT) Received: by mail-ua1-x930.google.com with SMTP id a1e0cc1a2514c-783fdeed241so345385241.1 for ; Wed, 17 May 2023 23:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684390111; x=1686982111; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aSWZec/J0A95SxR8LujGdt3ORI4eM1n8G0sqzEOmKqg=; b=VvJmt+2iJDjTXM5TCSHqebEa8w0nj/TQ09XLTx9AC1hDxo19cs9nvpCu0NVXOd6iEQ 2N0zEb/cv9ZznUf5cHO7bkzs9tfI3IJEdBhUkVbwHre/96lT3/TdqSy5p2Qt1CV/2QfK 1MRNQd+iDHqlIUSvzO6oc0muLxWQ26H1wk8mdQOmoKgTbZx0SgBCkckRBYHXThqEjJd0 b91FlwpFFL6Y7uQSAIgrSF6Gjbb9nLJrwB9Cd8CZAsv8EoUJ2Jn2S/ch358KVd1nKTfH Oh3y32wtrvvPLf89kPKQphChPENIwRHyBqX/6aZqnwq5YxIr1KttsW+JHKVY7KGl5pAg IxEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684390111; x=1686982111; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aSWZec/J0A95SxR8LujGdt3ORI4eM1n8G0sqzEOmKqg=; b=hfmpyp58ZrO/xwtD8o8LE0kRQ3FgqIqnMsMsDfYyZ2vlghBiUyw9hC1W7sTRUnBLuY c7wprwxHn1xMuxAOPNBHysgsM6FC4dR/mXzjxezydnEmlTvyypWmXbRoq1dGxGAIJa7M G589JnQldtHWVG6meuvTrdDyMt2RN5Cx/IxsRtJ8a4UlD7uf/M4zxHsb0q2mJPFfSMVD j2gzHxfqgiaZaeaYilUSfKcCjooKOZE/MOJj7X5WcZmuhXB/rFY8dj97wIeK6CvWd7e4 kOrssbeVeTm6nHYTdD9YthbOa2f9/Rxl+8fJV2bmoJ/Dy5DYgqxUtFrx6f1K4rB4hddm fQ8Q== X-Gm-Message-State: AC+VfDzfTnX7jDUiLn2iSxY49ejl/v88cPT5yQXAnYRwNGAeuGfw7HjQ 3+Xo+emC53ZvcU3vemiJGSHgzbvAPw5sZczFLc1kLQ== X-Received: by 2002:a67:ebcc:0:b0:434:768c:4966 with SMTP id y12-20020a67ebcc000000b00434768c4966mr157942vso.8.1684390110959; Wed, 17 May 2023 23:08:30 -0700 (PDT) MIME-Version: 1.0 References: <20230517031856.19660-1-xiaoming.ding@mediatek.com> In-Reply-To: From: Sumit Garg Date: Thu, 18 May 2023 11:38:20 +0530 Message-ID: Subject: Re: FOLL_LONGTERM vs FOLL_EPHEMERAL Re: [PATCH] tee: add FOLL_LONGTERM for CMA case when alloc shm To: Christoph Hellwig Cc: David Hildenbrand , Xiaoming Ding , Jens Wiklander , Matthias Brugger , AngeloGioacchino Del Regno , op-tee@lists.trustedfirmware.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, fei.xu@mediatek.com, srv_heupstream@mediatek.com, linux-mm@kvack.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 May 2023 at 09:51, Christoph Hellwig wrote: > > On Wed, May 17, 2023 at 08:23:33PM +0200, David Hildenbrand wrote: > > In general: if user space controls it -> possibly forever -> long-term. Even > > if in most cases it's a short delay: there is no trusting on user space. > > > > For example, iouring fixed buffers keep pages pinned until user space > > decides to unregistered the buffers -> long-term. > > > > Short-term is, for example, something like O_DIRECT where we pin -> DMA -> > > unpin in essentially one operation. > > Btw, one thing that's been on my mind is that I think we got the > polarity on FOLL_LONGTERM wrong. Instead of opting into the long term > behavior it really should be the default, with a FOLL_EPHEMERAL flag > to opt out of it. And every users of this flag is required to have > a comment explaining the life time rules for the pin.. It does look like a better approach to me given the very nature of user space pages. -Sumit