Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp976103pxu; Mon, 23 Nov 2020 08:38:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxjdY68lddnOs/3Vbu5rcuklAMC/0Nv7kg1FjcXdZ6QmmPbasaTwCSasQEYfKDdl0BooQFv X-Received: by 2002:a17:906:888b:: with SMTP id ak11mr422175ejc.278.1606149501254; Mon, 23 Nov 2020 08:38:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606149501; cv=none; d=google.com; s=arc-20160816; b=Z9SjnMZBeigLUXYlJ5pX+sjqtKz/15NmHY574331pPMNIx1XlpxC7VmQhVfyUO9VdG Nr2ySGbrcsodOMMrCWEABtpzvNgcPYpBVsCEAN5T5Jx0jjSVXcUsQNNts7luO55bM61v WCtJ5FuWh0w9mszaABSioA6GMudzQluZlZmSWGZuboVCLj5IUU8lhws9isGnK41S5ahY HmaYaMq6eTsqdAW3PMx5vRiRFL+8ouI6V4GhnbQX2UbsZAZHPHZsI1WeQ/fB9qgzouQq W3vziuO48/PADhUcUJyBqdg1lIVQTfuSsGwMaCFQmLk48MtZoWIocXQLLbLzAZcTPi0w tNEw== 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=PEbsa5HntcIdBOrGyUXi03wOc7HPqT6OCL9AKHl623g=; b=Xtz9jLp3wNBZ7CE3xZSgFWeRLu4sScHuUaVsWM6ygizJwjt8dqX8HxifqB2mTRTigR 6KS4s7Fjh+pXLhZkljy0TQcs+wdQzpECWXJFD60teDJj7dnrvTBhmD+I/2629URXVt1V d+qXlNQczm3QXj51FGuukiFEo6qshM7vZu5AAMSbFa4neXjmmM9lPuqMhsWi44yk2iEp 3+TCvDlSd0vCjJ23xULOzJDjopFmuIGZJPocezkJBeFof8xnzp+kBhYjuz01vDhgDNUo TnBBFoTBuzmK0m7zosvTF98wBHVi6RI6+NYJ1FN6Gdk0liBkgkXO1u/yaNN1/Jxm9I05 /gCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=JcEmEqmZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 22si6445193ejv.120.2020.11.23.08.37.56; Mon, 23 Nov 2020 08:38:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@soleen.com header.s=google header.b=JcEmEqmZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390091AbgKWQde (ORCPT + 99 others); Mon, 23 Nov 2020 11:33:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730635AbgKWQci (ORCPT ); Mon, 23 Nov 2020 11:32:38 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8238C0613CF for ; Mon, 23 Nov 2020 08:32:36 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id d18so17746059edt.7 for ; Mon, 23 Nov 2020 08:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PEbsa5HntcIdBOrGyUXi03wOc7HPqT6OCL9AKHl623g=; b=JcEmEqmZ5YVK3pKO04CD9oQmQCLnELQLzua8f5fXbSIiJnbSxM1z/pJlUKmuvdrff6 stFtRiKKcVo+tzBS2B+a0SPwL0Vizlvm8sKbSv8tqJcb3iVYLg557b9ZVNGpZlh1+Pmr kRVtCqShkcbuNliqdPmADaMb1KQr2MEPncsHK5QB3G+qH110ElyaG10C7ZRvZm+KE8Nd TfjZyeq3+gmJis6cKNWZ/N6mqrWENXzdHRxmfvKI+4mnBdFP0mW78bFvsirFFTgH5o01 6K6PcEQWA6Tongd41DiZaj5w5lpGxcDvg1jYwfT8pIPM2HyUD1m1ewAnXWMgh+63NcsP l9Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PEbsa5HntcIdBOrGyUXi03wOc7HPqT6OCL9AKHl623g=; b=SQjngnA+miIyl4gtuX4RjgYN7G5m8zftPw8+e8EI7tcG6SHICLz9QfOE/tGcFHVT/M HJokc2fE8921+VsWJoOJQcLKzAYDExmmuLmSyeSindIIk0q0x2RTHzflW9jDCdzQNoS6 wC02/Xgxg6AYpmqStQ880Sge9gXBlHuTGWyeMO9Xxy4bOXiGCjGW2TJGfFIBt0mcQ9lJ ygdvKNKwTVsF4ZAbxtgaXa+SEgwV9gHecYScYvcpom9vWLlji4ar05XGUt4LujgSVqjM 7gUMZC7veQKTs3Wm5gctLD1Ehr6zpjFuL8YluxqITClesqA/61sMz7sH7zlAy1hkZrPn bFjg== X-Gm-Message-State: AOAM530guJL+VoLByT/c7tKdpAKPn3XhzftboeAR+i17iywmN4fIgoOO BaG2kRWvb+ytCoql3JIi7tIhnYmTIfXeVQhefwPw+xhKoPQrAQ== X-Received: by 2002:a05:6402:1777:: with SMTP id da23mr38863edb.116.1606149155388; Mon, 23 Nov 2020 08:32:35 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Tatashin Date: Mon, 23 Nov 2020 11:31:59 -0500 Message-ID: Subject: Re: Pinning ZONE_MOVABLE pages To: Vlastimil Babka Cc: linux-mm , Andrew Morton , LKML , Michal Hocko , David Hildenbrand , Oscar Salvador , Dan Williams , Sasha Levin , Tyler Hicks , Joonsoo Kim , sthemmin@microsoft.com, John Hubbard Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Makes sense, as this means no userspace change. > > > 2. Add an internal move_pages_zone() similar to move_pages() syscall > > but instead of migrating to a different NUMA node, migrate pages from > > ZONE_MOVABLE to another zone. > > Call move_pages_zone() on demand prior to pinning pages from > > vfio_pin_map_dma() for instance. > > As others already said, migrating away before the longterm pin should be > the solution. IIRC it was one of the goals of long term pinning api > proposed long time ago by Peter Ziljstra I think? The implementation > that was merged relatively recently doesn't do that (yet?) for all > movable pages, just CMA, but it could. From what I can tell, CMA is not solving exactly this problem. It migrates pages from CMA before pinning, but it migrates them to ZONE_MOVABLE. Also, we still need to take care of the fault scenario. > > > 3. Perhaps, it also makes sense to add madvise() flag, to allocate > > pages from non-movable zone. When a user application knows that it > > will do DMA mapping, and pin pages for a long time, the memory that it > > allocates should never be migrated or hot-removed, so make sure that > > it comes from the appropriate place. > > The benefit of adding madvise() flag is that we won't have to deal > > with slow page migration during pin time, but the disadvantage is that > > we would need to change the user interface. > > It's best if we avoid involving userspace until it's shown that's it's > insufficient. Agree. Thank you, Pasha