Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1367186pxm; Thu, 3 Mar 2022 16:21:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJxavEtYKCIcUDP0nsi1Z7GMfV8nOhnBXmK98edSClI25YdwyczR58qw8fr+N+SfwVgQmV2Y X-Received: by 2002:a17:907:6d23:b0:6d9:ac9d:222 with SMTP id sa35-20020a1709076d2300b006d9ac9d0222mr9411156ejc.595.1646353278319; Thu, 03 Mar 2022 16:21:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646353278; cv=none; d=google.com; s=arc-20160816; b=qWL/FUWQN35qdc2PufZE/LFXnF8xlOLF9l09Mk7+btU91p1zr3qm8TTyfjJjla8ZW5 l/4suS0ovB8o1gaLqM5pwQ29gb3+Lhn2ObCp9dkh8/VVBjlBojywt5bNdwQt2MkGkbat otsGwJKP6ZhVcMAIXclADwlBnwZi8l8VJ2BjCiNesWCxKpPrVudsATSYJtLdvm+GdMW3 Sbqo3PFbKyzG2VG9T7/bI9QOJgLILaAm/1Jd53OqweNqpKYoDRj2FwLKl3LEAsLRjpJ5 Ys4HukbEDVyd6eh+1hNp1/9i5fG+KVrDDKEGHfRxsLHhvgEyOYidkx0hYOI2+oLHfqr4 bkgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=EZmBSf7RjPn5+sYY9ZdCSnzCqzjve1M3G+h5tfOhBH8=; b=P8l02yg6hCIAuwwMBYqKMFzhQ8QQPMB7oTay1dcXQwgX7mWb+cz/bu19niz7J51hnC Eq+0owL9BzKpekvdaOuk2C4zYJ20AuW7w+Aop3gBYM8lisVxKqZNJecLmq3leYapbox1 kZz0eUESFv+t/CmSMeH5LGp/4oIHLeXMoHL75DscsXejCxtuyG+0oiYMMV8bnVYNYHMe Z2tQKBxiUSGUYRn854Vdblo3vXQ+D14G/W5VKKeNaMruxoCob/zJQltxVUi5HQ9Ains7 TAmTk/9zX1YvQNk3uTAs3NX0ZozEu9eC/hD0YUm6ceRmXpSn9UPml+PVz30QnTqhHCml CgFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=weqSjXg8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc24-20020a1709071c1800b006da825b1354si2753357ejc.766.2022.03.03.16.20.54; Thu, 03 Mar 2022 16:21:18 -0800 (PST) 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=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=weqSjXg8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236850AbiCCW0H (ORCPT + 99 others); Thu, 3 Mar 2022 17:26:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231707AbiCCW0D (ORCPT ); Thu, 3 Mar 2022 17:26:03 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3BA7035260 for ; Thu, 3 Mar 2022 14:25:17 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id c4so5950846qtx.1 for ; Thu, 03 Mar 2022 14:25:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=EZmBSf7RjPn5+sYY9ZdCSnzCqzjve1M3G+h5tfOhBH8=; b=weqSjXg88DL4Q86PolMdKXQ5mcLbv9EpSztPGU/faQsSpAtE0vJmGGaDP07nvudbOR HlRcpr4wFeh7zj6oOvhAw1Qxo/n0IQD86jxZBv1aoZANW5MCuxxsBX1jF5qUB4digaml M6aQwmvYuF6vGvmfaCBhsDR/DJUIDW0sxydQ3REZ4oD6LpYnJlCe6EWcnNOpryZHu6BE zZMJLyWqECGso5RRrkzfoipFQbUfvh6F51VXy0U3j1ggR0I1mkD5W+FpiOmgfTmn1hjM R+nLoFEz/W0Lgv3ofiAkUicR5eKVWbXSRfOEeB1yWvTu9TVALje1Cu3jsl103dsWB2ei +Umw== 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:content-transfer-encoding :in-reply-to; bh=EZmBSf7RjPn5+sYY9ZdCSnzCqzjve1M3G+h5tfOhBH8=; b=NNRWnDN5XhC3889TGSVpnBdQ97/bmPxPpQRPn9u+Q0mnQ8eSYwpDgEqXC8pTJS9BvZ +/GaVrA95XTHlMGeca0DI3uJRzdYvBUoxXp0WpJ0ZJv7+qNSHG8WRA9GLNBy2ns3R5DH ChmjVI7RWIXacM0iSdkgmyo2GebFlM2u2DbGsEVR40gsUFp1aTWAFQjPN2hj+iqObPK8 DryL2MC7bcSimVp5YieOQpLYlQRrlIoVuQhaYqypYQafTUy7PsBfkAUiKNWXggi4ZzdY pN44g4yO0NQCgcwX5LD4Z6J5Vif5pGCa1mg0Gw4ltFSaWzMUvGNl2o+kEBbcw+D/zEhb 1H8A== X-Gm-Message-State: AOAM530LA6p+zP3Cg5e2Vk7DDH1bxEskeWRBUA+PT/p/CB7h/2s2H3P1 Gpum9uuwBougiZDjqwf1HJtStr5FiEDJNQ== X-Received: by 2002:ac8:5cd5:0:b0:2d0:6770:c997 with SMTP id s21-20020ac85cd5000000b002d06770c997mr29105165qta.178.1646346316452; Thu, 03 Mar 2022 14:25:16 -0800 (PST) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id v14-20020a05622a014e00b002cf75f5b11esm2290185qtw.64.2022.03.03.14.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 14:25:15 -0800 (PST) Date: Thu, 3 Mar 2022 17:25:15 -0500 From: Johannes Weiner To: Nadav Amit Cc: Andrew Morton , Michal Hocko , Vlastimil Babka , Linux-MM , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: madvise: MADV_DONTNEED_LOCKED Message-ID: References: <20220303212956.229409-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,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, Mar 03, 2022 at 01:35:56PM -0800, Nadav Amit wrote: > > > > On Mar 3, 2022, at 1:29 PM, Johannes Weiner wrote: > > > > MADV_DONTNEED historically rejects mlocked ranges, but with > > MLOCK_ONFAULT and MCL_ONFAULT allowing to mlock without populating, > > there are valid use cases for depopulating locked ranges as well. > > ... > > > @@ -850,7 +858,7 @@ static long madvise_dontneed_free(struct vm_area_struct *vma, > > VM_WARN_ON(start >= end); > > } > > > > - if (behavior == MADV_DONTNEED) > > + if (behavior == MADV_DONTNEED || behavior == MADV_DONTNEED_LOCKED) > > return madvise_dontneed_single_vma(vma, start, end); > > else if (behavior == MADV_FREE) > > return madvise_free_single_vma(vma, start, end); > > @@ -988,6 +996,7 @@ static int madvise_vma_behavior(struct vm_area_struct *vma, > > return madvise_pageout(vma, prev, start, end); > > case MADV_FREE: > > case MADV_DONTNEED: > > + case MADV_DONTNEED_LOCKED: > > return madvise_dontneed_free(vma, prev, start, end, behavior); > > case MADV_POPULATE_READ: > > case MADV_POPULATE_WRITE: > > @@ -1113,6 +1122,7 @@ madvise_behavior_valid(int behavior) > > case MADV_REMOVE: > > case MADV_WILLNEED: > > case MADV_DONTNEED: > > + case MADV_DONTNEED_LOCKED: > > case MADV_FREE: > > case MADV_COLD: > > case MADV_PAGEOUT: > > Don’t you want to change madvise_need_mmap_write() as well and add > MADV_DONTNEED_LOCKED there too? You're absolutely right, thanks Nadav! It'd be fine, but more expensive than necessary. Here is the fixlet: diff --git a/mm/madvise.c b/mm/madvise.c index 12dfa14bc985..7dbfcd6c955a 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -52,6 +52,7 @@ static int madvise_need_mmap_write(int behavior) case MADV_REMOVE: case MADV_WILLNEED: case MADV_DONTNEED: + case MADV_DONTNEED_LOCKED: case MADV_COLD: case MADV_PAGEOUT: case MADV_FREE: