Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5575991ybi; Tue, 4 Jun 2019 08:41:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzEWJvX/6jZbA1m5F5+yaR+QP21xsMx48NRPDPuNIXbJCBovH419UBg0t0RiVoDXttc1C3L X-Received: by 2002:a63:cc43:: with SMTP id q3mr36265562pgi.438.1559662872475; Tue, 04 Jun 2019 08:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559662872; cv=none; d=google.com; s=arc-20160816; b=J23agWd38zV24fcJCb7GV60Uamf7Q/XOSU7HxXm3H10hgZ6t76r1B4aknrpqa5+2t/ MqlJl8l2pKkBNwBS70KGql39/0rYjhkHEjL/0iqOu93Uw+Q5W2PbJGZGWGNJioRq7hIg 8lEPJDsS2cahxkSQAkOWT0AcPx1bdnB8ficb3ONmm9jyQaO3iq/dey50T5en11EfjTDa fbdXK3En2N5/10iNEBJYcnvhJ6sUB844Sqdqu7TTp5shT2q3nTlkUnrtHPNo6p10eWQt DVu0Wg3KgGZ5xGtQLc+s+c1z43wiYlLkbDiHewJLNtjeUPTg9ISNVTNcUgrqT5A2uQ+W KpDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :references:message-id:in-reply-to:subject:cc:to:from:date :dkim-signature; bh=lvfCdm4b8tnmE7fUJNiFD0bSN1ROrrVNwrJCSfbuLfk=; b=b40g6/luAh4RDZKbYmyYiO/AhuvKH3tR0TzMu27QmJlAGvg6rIpWco0OiCH/6DOe8c UJndEeJjhRPqbmfML5iBadh+ZLFVyI78CWehCTeuJ7D1Ob0fUjZBozD+cK4YUr7iIYRo RCXW3LqPLZIiIrZsmPscxpwwRrsZLNZgprPj+KmV6kvglsUeGlUKfDtfgmv0uJHsWLIt kLGDJ+NQ4cpalRWOVnaBbjZ8e4e18oRbBUPktVQhRlqyHiZpANS9RxlUBQAtsijug74+ ZSu9IhUAs/9UrsebIXkJxe+HVvUXCzUQL6RrGkOcmbFf0TgVY+dX0lqWZ/IpR3eIKEzw OQMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazonses.com header.s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw header.b=ZYNwKBfh; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m15si22194198pgl.300.2019.06.04.08.40.53; Tue, 04 Jun 2019 08:41:12 -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=@amazonses.com header.s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw header.b=ZYNwKBfh; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728129AbfFDPiV (ORCPT + 99 others); Tue, 4 Jun 2019 11:38:21 -0400 Received: from a9-99.smtp-out.amazonses.com ([54.240.9.99]:50926 "EHLO a9-99.smtp-out.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbfFDPiV (ORCPT ); Tue, 4 Jun 2019 11:38:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=6gbrjpgwjskckoa6a5zn6fwqkn67xbtw; d=amazonses.com; t=1559662700; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References:MIME-Version:Content-Type:Feedback-ID; bh=OIhqYY+SOkOUs9T6s6IEPEZv9lMASXYu4UBAM6SEZvE=; b=ZYNwKBfhOkfV60g9kU9G7VB5OM0s231pfDNM3QuvIazUXNFVO7bjE5m0pNNNMQec mEU2+GxAR9kUbYrODxURkYyW8OfS7B5BnJz4CvBknHYYByKfjas7oyCwT1qOsv54YQE sODGtZoWQg96VqyeEDuBs0l2tlZz6jNwzoqkr9iE= Date: Tue, 4 Jun 2019 15:38:20 +0000 From: Christopher Lameter X-X-Sender: cl@nuc-kabylake To: Minchan Kim cc: Andrew Morton , linux-mm , LKML , linux-api@vger.kernel.org, Michal Hocko , Johannes Weiner , Tim Murray , Joel Fernandes , Suren Baghdasaryan , Daniel Colascione , Shakeel Butt , Sonny Rao , Brian Geffon , jannh@google.com, oleg@redhat.com, christian@brauner.io, oleksandr@redhat.com, hdanton@sina.com Subject: Re: [PATCH v1 4/4] mm: introduce MADV_PAGEOUT In-Reply-To: <20190603053655.127730-5-minchan@kernel.org> Message-ID: <0100016b232425c9-64a09298-59ba-48b8-9aa3-e7e1ad2d316c-000000@email.amazonses.com> References: <20190603053655.127730-1-minchan@kernel.org> <20190603053655.127730-5-minchan@kernel.org> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SES-Outgoing: 2019.06.04-54.240.9.99 Feedback-ID: 1.us-east-1.fQZZZ0Xtj2+TD7V5apTT/NrT6QKuPgzCT/IC7XYgDKI=:AmazonSES Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 3 Jun 2019, Minchan Kim wrote: > @@ -415,6 +416,128 @@ static long madvise_cold(struct vm_area_struct *vma, > return 0; > } > > +static int madvise_pageout_pte_range(pmd_t *pmd, unsigned long addr, > + unsigned long end, struct mm_walk *walk) > +{ > + pte_t *orig_pte, *pte, ptent; > + spinlock_t *ptl; > + LIST_HEAD(page_list); > + struct page *page; > + int isolated = 0; > + struct vm_area_struct *vma = walk->vma; > + unsigned long next; > + > + if (fatal_signal_pending(current)) > + return -EINTR; > + > + next = pmd_addr_end(addr, end); > + if (pmd_trans_huge(*pmd)) { > + ptl = pmd_trans_huge_lock(pmd, vma); > + if (!ptl) > + return 0; > + > + if (is_huge_zero_pmd(*pmd)) > + goto huge_unlock; > + > + page = pmd_page(*pmd); > + if (page_mapcount(page) > 1) > + goto huge_unlock; > + > + if (next - addr != HPAGE_PMD_SIZE) { > + int err; > + > + get_page(page); > + spin_unlock(ptl); > + lock_page(page); > + err = split_huge_page(page); > + unlock_page(page); > + put_page(page); > + if (!err) > + goto regular_page; > + return 0; > + } I have seen this before multiple times. Is there a way to avoid replicating the whole shebang?