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 8EE52C433EF for ; Mon, 22 Nov 2021 20:09:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F07BD6B0071; Mon, 22 Nov 2021 15:09:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB7CB6B0072; Mon, 22 Nov 2021 15:09:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D57D26B0073; Mon, 22 Nov 2021 15:09:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id C81EA6B0071 for ; Mon, 22 Nov 2021 15:09:02 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 8521918313C5A for ; Mon, 22 Nov 2021 20:08:52 +0000 (UTC) X-FDA: 78837654504.03.72B62A0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 2803230019C6 for ; Mon, 22 Nov 2021 20:08:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1637611731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wx9owdJOrmjGXLWEhFvkrVgkkHwU/2JlwqTvYXsyeFw=; b=TqxE3/VE9R+psUEWcF3Rizu94GU0aTW5u+zs4gdvyD6NaeYokSLZPzVRvq6s0ck19ZDgSu 5qhogR8oIOWDIKv11GMFRqKYPKlw4Qu6aX2gz3+qNxsSanrbmLrUmBZTBVxDkKJ4mXQ4Zm NFGwDk64KV2HndjqSBZ8eazclo/5m44= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-248-AsEC-Z8jP5q6ksM_j7mlPA-1; Mon, 22 Nov 2021 15:08:50 -0500 X-MC-Unique: AsEC-Z8jP5q6ksM_j7mlPA-1 Received: by mail-wm1-f72.google.com with SMTP id l4-20020a05600c1d0400b00332f47a0fa3so399051wms.8 for ; Mon, 22 Nov 2021 12:08:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=wx9owdJOrmjGXLWEhFvkrVgkkHwU/2JlwqTvYXsyeFw=; b=ctsqG/HD45HVhsjnewCdm3AHPqvf+RtCVhmjQj0wikes8GsLJtdF4FWCKeddhljTwa W5OfTP37aQGe4V44kqqGD32QO9y+QSil2A/lNZ8AC5oPQOklcfD2JgRg+1Izfkeh40UU VXYxJZiqkTiqDQtXgRIMAYapZntdmH20BTSNW+lpl/Hq6MyvaVw6t5zrbFiQqOFU+8Oh SBNmZXJ+zwlpgH6CscN2/ydwib9S4Sg0HNmaUnyEUHcxGqT/YBODcKk56/Iz+cFuJssB /1oYKWQgP0VBFw6eCUySf6I9p4VijBbmlEy3moqkcw+SDuked2EkRRNyf6nwGdYUUBAf u3QA== X-Gm-Message-State: AOAM530racxeiMOeAPJb9caPYm0PDH353vtMvk1YfPd4lRD/E66R6HtV HW8+b2xVfCxSl1DlwGxzPUfqJoQOEJP/OMidsVAJyLLUemiy4cE0Bd7tKrarAxmmGn3MSmWX8LT V+73OkGH6tzk= X-Received: by 2002:a1c:4c19:: with SMTP id z25mr33463171wmf.177.1637611728788; Mon, 22 Nov 2021 12:08:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4rF1zQh8IxxZ21UD3M7noCmiFkX9+K7yUl3FtS0Rnvm9Mdu8ZgNai9WbpFa7URCgixu8GMQ== X-Received: by 2002:a1c:4c19:: with SMTP id z25mr33463131wmf.177.1637611728568; Mon, 22 Nov 2021 12:08:48 -0800 (PST) Received: from [192.168.3.132] (p5b0c667b.dip0.t-ipconnect.de. [91.12.102.123]) by smtp.gmail.com with ESMTPSA id l5sm24227434wms.16.2021.11.22.12.08.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Nov 2021 12:08:47 -0800 (PST) Message-ID: <5f998bb7-7b5d-9253-2337-b1d9ea59c796@redhat.com> Date: Mon, 22 Nov 2021 21:08:47 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 To: Jens Axboe , Andrew Dona-Couch , Andrew Morton , Drew DeVault Cc: Ammar Faizi , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, io_uring Mailing List , Pavel Begunkov , linux-mm@kvack.org References: <20211028080813.15966-1-sir@cmpwn.com> <593aea3b-e4a4-65ce-0eda-cb3885ff81cd@gnuweeb.org> <20211115203530.62ff33fdae14927b48ef6e5f@linux-foundation.org> <20211116114727.601021d0763be1f1efe2a6f9@linux-foundation.org> <20211116133750.0f625f73a1e4843daf13b8f7@linux-foundation.org> <8f219a64-a39f-45f0-a7ad-708a33888a3b@www.fastmail.com> <333cb52b-5b02-648e-af7a-090e23261801@redhat.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] Increase default MLOCK_LIMIT to 8 MiB In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 2803230019C6 X-Stat-Signature: 4u6nbdezptquudxcdnqqdew87gn9mk89 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="TqxE3/VE"; spf=none (imf03.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1637611729-865437 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 22.11.21 20:53, Jens Axboe wrote: > On 11/22/21 11:26 AM, David Hildenbrand wrote: >> On 22.11.21 18:55, Andrew Dona-Couch wrote: >>> Forgive me for jumping in to an already overburdened thread. But can >>> someone pushing back on this clearly explain the issue with applying >>> this patch? >> >> It will allow unprivileged users to easily and even "accidentally" >> allocate more unmovable memory than it should in some environments. Such >> limits exist for a reason. And there are ways for admins/distros to >> tweak these limits if they know what they are doing. > > But that's entirely the point, the cases where this change is needed are > already screwed by a distro and the user is the administrator. This is > _exactly_ the case where things should just work out of the box. If > you're managing farms of servers, yeah you have competent administration > and you can be expected to tweak settings to get the best experience and > performance, but the kernel should provide a sane default. 64K isn't a > sane default. 0.1% of RAM isn't either. > >> This is not a step into the right direction. This is all just trying to >> hide the fact that we're exposing FOLL_LONGTERM usage to random >> unprivileged users. >> >> Maybe we could instead try getting rid of FOLL_LONGTERM usage and the >> memlock limit in io_uring altogether, for example, by using mmu >> notifiers. But I'm no expert on the io_uring code. > > You can't use mmu notifiers without impacting the fast path. This isn't > just about io_uring, there are other users of memlock right now (like > bpf) which just makes it even worse. 1) Do we have a performance evaluation? Did someone try and come up with a conclusion how bad it would be? 2) Could be provide a mmu variant to ordinary users that's just good enough but maybe not as fast as what we have today? And limit FOLL_LONGTERM to special, privileged users? 3) Just because there are other memlock users is not an excuse. For example, VFIO/VDPA have to use it for a reason, because there is no way not do use FOLL_LONGTERM. > > We should just make this 0.1% of RAM (min(0.1% ram, 64KB)) or something > like what was suggested, if that will help move things forward. IMHO the > 32MB machine is mostly a theoretical case, but whatever . 1) I'm deeply concerned about large ZONE_MOVABLE and MIGRATE_CMA ranges where FOLL_LONGTERM cannot be used, as that memory is not available. 2) With 0.1% RAM it's sufficient to start 1000 processes to break any system completely and deeply mess up the MM. Oh my. No, I don't like this, absolutely not. I neither like raising the memlock limit as default to such high values nor using FOLL_LONGTERM in cases where it could be avoided for random, unprivileged users. But I assume this is mostly for the records, because I assume nobody cares about my opinion here. -- Thanks, David / dhildenb