Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1315189imm; Fri, 8 Jun 2018 13:56:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJatt3Hzznr6DLgiSAi8KXujJDiNXRKJUfmgInYH5x2s135+6tYjWcV24RO4boug+xGhndT X-Received: by 2002:a63:ac11:: with SMTP id v17-v6mr6639802pge.274.1528491387380; Fri, 08 Jun 2018 13:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528491387; cv=none; d=google.com; s=arc-20160816; b=YaXbHM1Njziz6rhdIVVDwLaCtfClKySHsD1PnRFw5NNDMJ/l7dWHWvW3UTBDmEy49a Bx6qUok8FguJFZcTg9ugGHU8DuvryIv0nGOJmWyaLmmQwi231oaREIaQCWjjmU5PGAlk OK5MnW09EiLvL7dMygTcuzL4x54wc9u01v+cblIy4AhD/aQ2fBGbLxASAnJ8l9mAngKF rt+rc7XDKVEkqdm+vx+aM+b01zhiCfI5ygoGSKq3idmLJ3Ct5xMnKCf5eyUpS1SG7YB2 JWlS4PffBGK2QrNvdlo1YJjvgy0snEnU4IuLqUal/WXjq52Ip2XFPDxRGsI2LPFDFXqb UgQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=36ynMn/ar2uXtK+DL42esEmk6UobHIMVITpqwWLDAcw=; b=DqcjXYW3glgoWYlmPwcCZrxHeUf4F4yXMbRZW5ZvmZfi3hnjvZ+7tsAlP5X5n4vLv1 QDhgxJ+43MIDzkI0efFlPA5DnGHs/7raBlDEnAEe1VagPOEQUwgvZAFGrl3L0WWV4l8x YBTMzIQf0kyX7t/+8AuKBrvOunSb0J8gg2LrXhQ6auoejmUfDnsPlsDZ0YoxC9q7PZvB r/XfgN5D1zAQawrgCdSUN3CmcdVdV6fpa1fIbAQSfj/xQpwaFHzfgOXjsjfFJsRA1HaQ 6ddaWM5S+uQrV0QjBcsNp+e3Hub6994c/F603rBaJM8mJwA27w/2Z0SqKD6DUyCT8l3d Qutw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b=aON96YC3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s14-v6si19629831pgo.314.2018.06.08.13.56.13; Fri, 08 Jun 2018 13:56:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@akamai.com header.s=jan2016.eng header.b=aON96YC3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=akamai.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753037AbeFHUzu (ORCPT + 99 others); Fri, 8 Jun 2018 16:55:50 -0400 Received: from mx0a-00190b01.pphosted.com ([67.231.149.131]:58146 "EHLO mx0a-00190b01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752910AbeFHUzt (ORCPT ); Fri, 8 Jun 2018 16:55:49 -0400 Received: from pps.filterd (m0122333.ppops.net [127.0.0.1]) by mx0a-00190b01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w58KlflU029388; Fri, 8 Jun 2018 21:55:34 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akamai.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=jan2016.eng; bh=36ynMn/ar2uXtK+DL42esEmk6UobHIMVITpqwWLDAcw=; b=aON96YC3Z4NtqtvMfDfWb9+Fmbnb2/5flS1Vt/K9+yM1Ud2Dc3kCCnNMjU8hqNWlu9FQ BmoByt+H98SLWBgr0M7jE7gfLMQT/v7YQtV0E5m8t9+tr4MCzFwrXNYEy8YGDG9wotyd g4rkXC+vKYT4dy+64PB5Z97SB6ec5dDpeuUTrZeLC83JFezbw/R2gHiRn20CK56bBnSD CyD7KnoPAO7jveeNLr0DXCcVQWaYOSQLZGpG8rywoGEimjmYvbPBy9mvqbHAFoC1AkCP lRuGN92sPyV/U5OtEGhWQBhZ5gH+YnIEFYqL3GZgkp2bjgzPp0Ki4/aYm7O69TVGz2ns vg== Received: from prod-mail-ppoint4 (a96-6-114-87.deploy.static.akamaitechnologies.com [96.6.114.87] (may be forged)) by mx0a-00190b01.pphosted.com with ESMTP id 2jeyggpjak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Jun 2018 21:55:34 +0100 Received: from pps.filterd (prod-mail-ppoint4.akamai.com [127.0.0.1]) by prod-mail-ppoint4.akamai.com (8.16.0.21/8.16.0.21) with SMTP id w58KkRnA003194; Fri, 8 Jun 2018 16:55:30 -0400 Received: from prod-mail-relay14.akamai.com ([172.27.17.39]) by prod-mail-ppoint4.akamai.com with ESMTP id 2jbpjwcjbq-1; Fri, 08 Jun 2018 16:55:30 -0400 Received: from [172.28.13.175] (bos-lpjec.kendall.corp.akamai.com [172.28.13.175]) by prod-mail-relay14.akamai.com (Postfix) with ESMTP id D611880FAE; Fri, 8 Jun 2018 20:55:29 +0000 (GMT) Subject: Re: [PATCH] mm/madvise: allow MADV_DONTNEED to free memory that is MLOCK_ONFAULT To: Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Michal Hocko , Vlastimil Babka , Joonsoo Kim , Mel Gorman , "Kirill A. Shutemov" References: <1528484212-7199-1-git-send-email-jbaron@akamai.com> <20180608125717.c34d3e7125c62fc91ac427c8@linux-foundation.org> From: Jason Baron Message-ID: Date: Fri, 8 Jun 2018 16:55:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180608125717.c34d3e7125c62fc91ac427c8@linux-foundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-08_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806080225 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-06-08_09:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1805220000 definitions=main-1806080225 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/08/2018 03:57 PM, Andrew Morton wrote: > On Fri, 8 Jun 2018 14:56:52 -0400 Jason Baron wrote: > >> In order to free memory that is marked MLOCK_ONFAULT, the memory region >> needs to be first unlocked, before calling MADV_DONTNEED. And if the region >> is to be reused as MLOCK_ONFAULT, we require another call to mlock2() with >> the MLOCK_ONFAULT flag. >> >> Let's simplify freeing memory that is set MLOCK_ONFAULT, by allowing >> MADV_DONTNEED to work directly for memory that is set MLOCK_ONFAULT. The >> locked memory limits, tracked by mm->locked_vm do not need to be adjusted >> in this case, since they were charged to the entire region when >> MLOCK_ONFAULT was initially set. > > Seems useful. > > Is a manpage update planned? > Yes, I will add a manpage update. I sort of wanted to see first if people thought this patch was a reasonable thing to do. > Various updates to tools/testing/selftests/vm/* seem appropriate. > Indeed, I started updating tootls/testing/selftests/vm/mlock2-tests.c with this new interface, but then I realized that that test is failing before I made any changes. So I will go back and sort that out, and add additional testing for this new interface. >> Further, I don't think allowing MADV_FREE for MLOCK_ONFAULT regions makes >> sense, since the point of MLOCK_ONFAULT is for userspace to know when pages >> are locked in memory and thus to know when page faults will occur. > > This sounds non-backward-compatible? > I was making the point of why I think allowing 'MADV_DONTNEED' for MLOCK_ONFAULT regions makes sense, while allowing 'MADV_FREE' for MLOCK_ONFAULT regions really does not. Thanks, -Jason