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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FCB4C433EF for ; Wed, 24 Nov 2021 13:48:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D5B4B6B0078; Wed, 24 Nov 2021 08:48:24 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D0B4D6B007B; Wed, 24 Nov 2021 08:48:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAC976B007D; Wed, 24 Nov 2021 08:48:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0042.hostedemail.com [216.40.44.42]) by kanga.kvack.org (Postfix) with ESMTP id A9C3F6B0078 for ; Wed, 24 Nov 2021 08:48:24 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 726A7184C115F for ; Wed, 24 Nov 2021 13:48:14 +0000 (UTC) X-FDA: 78843952908.08.190336A Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) by imf21.hostedemail.com (Postfix) with ESMTP id E1ABDD036A55 for ; Wed, 24 Nov 2021 13:48:11 +0000 (UTC) Received: by mail-qk1-f180.google.com with SMTP id a11so2778329qkh.13 for ; Wed, 24 Nov 2021 05:48:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=zOXzKhqaRx2erCZtsz+9xALkHd9hNx/cLSQi9Yty6Mg=; b=mqWQPtKzwOR1nkPAD7jr3kr0122cp3KDzbkHN+B+BxUbqGHwEj/KwFx+nzOZg5/uMv yIUSS+MqQcFr+VNaaOdQL2d54qPlp7/uaU1vDWm0bWF/WUjZxiC0fvnyOfXDQtl5pj2C yfEPRxdcQqW0bzw/xo4luil1ejPlXbTZKMrVa3O9+CFypBK9Vxa2Fb/Wi+5LRCM/2Ej+ KnIDGXrj+FdBk+m0nclivosH7G9FNhn/mQQycUFZZyEdlBbOlaakTvIJcZrMjFupixhJ 0E9iiTnkyJ7//qXBW+4wpIgh/iwCuzV8L27KLQvBSD4qycVQcE7fubpABBHpq7dcXbai 5nxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=zOXzKhqaRx2erCZtsz+9xALkHd9hNx/cLSQi9Yty6Mg=; b=P+WXr7/YGvVycTRBlFqvsjsf3DHxum7wzIle5Er1nsGutZEUtYWHfVUfQJaK6Q43/m x0atAgxcN05Wb0ugePZf9OX6h+y2sx6MWvaUEYPCaJ5XY7unzfq8QzKHsp9kofGGYcAy fkGbtAmCeFRGB/uLxURE/nYV6PPZVwbDtnvvdo0j7o7Ufrv9meyFO2snPtZ+BT1pDxhl +aJFbUjuIbqlRMHTJHHmBmM/ojUIqGpiijAE9c3tIxdLxqwJi++u2rXv9GEEWnqv/g3I F5MjJR/rpqEF3wvpO5q9lhOjPKqPspTjaU7CrzLTtjQJQKTP55gylq55LyWuxo6syeD2 GK7A== X-Gm-Message-State: AOAM533NQgbK3OpA3ol/PF/RmOgs55r3NU6E/vvGaFjmwd7n/ieudVtj fdJhXVk3tS0YidOWM/FsSB5KzA== X-Google-Smtp-Source: ABdhPJzQ5AOoy19Xqda8lOZ1Zk6QX+7bxb6Q0xD34+IJfiCzMeF/udwWMkqUf3c7/DV2nUZ9JOgtyg== X-Received: by 2002:a05:620a:22f5:: with SMTP id p21mr6352722qki.498.1637761693453; Wed, 24 Nov 2021 05:48:13 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-113-129.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.113.129]) by smtp.gmail.com with ESMTPSA id o126sm7924464qke.11.2021.11.24.05.48.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Nov 2021 05:48:12 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1mpsdA-0011Y1-BA; Wed, 24 Nov 2021 09:48:12 -0400 Date: Wed, 24 Nov 2021 09:48:12 -0400 From: Jason Gunthorpe To: David Hildenbrand Cc: Vlastimil Babka , Jens Axboe , Andrew Dona-Couch , Andrew Morton , Drew DeVault , Ammar Faizi , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, io_uring Mailing List , Pavel Begunkov , linux-mm@kvack.org Subject: Re: [PATCH] Increase default MLOCK_LIMIT to 8 MiB Message-ID: <20211124134812.GI5112@ziepe.ca> References: <20211123140709.GB5112@ziepe.ca> <20211123170056.GC5112@ziepe.ca> <20211123235953.GF5112@ziepe.ca> <2adca04f-92e1-5f99-6094-5fac66a22a77@redhat.com> <20211124132353.GG5112@ziepe.ca> <20211124132842.GH5112@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E1ABDD036A55 X-Stat-Signature: gqfawm4nx64446o6o8ohyq8qkjf9q9aq Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=ziepe.ca header.s=google header.b=mqWQPtKz; dmarc=none; spf=pass (imf21.hostedemail.com: domain of jgg@ziepe.ca designates 209.85.222.180 as permitted sender) smtp.mailfrom=jgg@ziepe.ca X-HE-Tag: 1637761691-813963 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 24, 2021 at 02:29:38PM +0100, David Hildenbrand wrote: > On 24.11.21 14:28, Jason Gunthorpe wrote: > > On Wed, Nov 24, 2021 at 02:25:09PM +0100, David Hildenbrand wrote: > >> On 24.11.21 14:23, Jason Gunthorpe wrote: > >>> On Wed, Nov 24, 2021 at 09:57:32AM +0100, David Hildenbrand wrote: > >>> > >>>> Unfortunately it will only be a band aid AFAIU. I can rewrite my > >>>> reproducer fairly easily to pin the whole 2M range first, pin a second > >>>> time only a single page, and then unpin the 2M range, resulting in the > >>>> very same way to block THP. (I can block some THP less because I always > >>>> need the possibility to memlock 2M first, though). > >>> > >>> Oh! > >>> > >>> The issue is GUP always pins an entire compound, no matter how little > >>> the user requests. > >> > >> That's a different issue. I make sure to split the compound page before > >> pinning anything :) > > > > ?? Where is that done in GUP? > > It's done in my reproducer manually. Aren't there many ways for hostile unpriv userspace to cause memory fragmentation? You are picking on pinning here, but any approach that forces the kernel to make a kalloc on a THP subpage would do just as well. Arguably if we want to point to an issue here it is in MADV_FREE/etc that is the direct culprit in allowing userspace to break up THPs and then trigger fragmentation. If the objective is to prevent DOS of THP then MADV_FREE should conserve the THP and migrate the subpages to non-THP memory. FOLL_LONGTERM is not the issue here. Jason