Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6942402ybl; Mon, 23 Dec 2019 15:12:21 -0800 (PST) X-Google-Smtp-Source: APXvYqzpGnJvO9EMwnL/YGUO1UsjprSENBQpX1WW9aLoPcI97TFYQ4xpKv2WLUJwK0XG6svAdBUN X-Received: by 2002:a05:6830:4d5:: with SMTP id s21mr18876403otd.294.1577142740998; Mon, 23 Dec 2019 15:12:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577142740; cv=none; d=google.com; s=arc-20160816; b=nMbXYs8HHJfRcJyuB/b1brLhzlyvi/pfZZSk+KR0SqgDWM+wycETJ5yv0J6pzk8IRm HsEaqUJGFFdVfVBh0HvT5WB7B8D5guae4ToqZN0U7sIEefgd5eaLDC/uJ7BYPU0WWAsD N7I9eIqi6MlqIj49OVURa3ji5ii4M//hmgLZ2QxX6t3+qN0HGxYn3ThepwCI0EqPzQBF dz/ltII9NF2GSM6Y00ecMPB8qqPL3IoL0O/s7yCD2iGxDbtaasS/+4imoAJ+Jdo/qTsm 4Jrml81bCwlw5VMtaizoaCyyYexzoICrmv/8wykG7vmaERcgO/YaYTdZH7Zeyb90/Y/l Q98A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=8UqunE6pGKgBFGh/0KYtTzCv0Na6jyRZMicJ6zr2gBA=; b=y2K1mfwVy+neslym1CsBx9nvJk/VZ7JdNXYD395olaA9ezYTaVNvNu/w4M3w6FGkNl M4uJln8CsQJvzX0BpmrB/hVjGjATU/7UwMB4WH5JtahWQXVX5uYcD7cmoUCkgvlbpqmu Z5Mci33Q71KhHaPZc2sPX8Qtyz72e3ppHYE+0Vo1w+vZyNc4I8fa6b0KVtHXMLBjYQ+I Jkj0Xc4VrIJHPT1VxvG7Rl59Xqs+CBOr8teVA9+UDxQ7rPW1hiSDD4ly7JlOoaMrq3vS n0GYuMEj5cMntzzVlYyDozDBj349tqaEnZ9PUOLtQdx4CTIksK5w7SriFK7oqFHb1Lii yP7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (dns failure for signature) header.i=@infradead.org header.s=bombadil.20170209 header.b=sgHy6VMU; 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 r1si11109887otq.298.2019.12.23.15.12.08; Mon, 23 Dec 2019 15:12:20 -0800 (PST) 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=temperror (dns failure for signature) header.i=@infradead.org header.s=bombadil.20170209 header.b=sgHy6VMU; 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 S1726861AbfLWXLY (ORCPT + 99 others); Mon, 23 Dec 2019 18:11:24 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:43744 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726512AbfLWXLY (ORCPT ); Mon, 23 Dec 2019 18:11:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8UqunE6pGKgBFGh/0KYtTzCv0Na6jyRZMicJ6zr2gBA=; b=sgHy6VMUuDdjbg+SJ7kYPqOGz vLZWV459e0hnwluTTXSS5VfDCzpVrRLfVsgNgsv+w9N9ENuylDt+3ucrxUKChU9AvbLZaUa7ndKS/ RGTTkZblZFEkSICjCEKQzZaYefus3p4q0abDkiB/w8PHoCmGVKrUvvWX7tt9GS3sSUSmeJ+fmH0eU Gm6Jm29U3VrH1gT+AJ6RALKWbtO/m8zFMlyvMjlHKUeV0k1YGNlEDGCjrly0iAyfrkU7vUYqgSAt/ tyasLxK80fWnF8sJsOEtDqOfGKpBv/xbH/jpEd+6a550XR4j1pUoUdn4PdeKIv1aon6Is9OnGxB/N g9v+NisMg==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1ijWrB-0003my-0m; Mon, 23 Dec 2019 23:11:21 +0000 Date: Mon, 23 Dec 2019 15:11:20 -0800 From: Matthew Wilcox To: Wei Yang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kirill.shutemov@linux.intel.com Subject: Re: [Patch v2] mm/rmap.c: split huge pmd when it really is Message-ID: <20191223231120.GA31820@bombadil.infradead.org> References: <20191223222856.7189-1-richardw.yang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191223222856.7189-1-richardw.yang@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 24, 2019 at 06:28:56AM +0800, Wei Yang wrote: > When page is not NULL, function is called by try_to_unmap_one() with > TTU_SPLIT_HUGE_PMD set. There are two cases to call try_to_unmap_one() > with TTU_SPLIT_HUGE_PMD set: > > * unmap_page() > * shrink_page_list() > > In both case, the page passed to try_to_unmap_one() is PageHead() of the > THP. If this page's mapping address in process is not HPAGE_PMD_SIZE > aligned, this means the THP is not mapped as PMD THP in this process. > This could happen when we do mremap() a PMD size range to an un-aligned > address. > > Currently, this case is handled by following check in __split_huge_pmd() > luckily. > > page != pmd_page(*pmd) > > This patch checks the address to skip some work. The description here is confusing to me. > + /* > + * When page is not NULL, function is called by try_to_unmap_one() > + * with TTU_SPLIT_HUGE_PMD set. There are two places set > + * TTU_SPLIT_HUGE_PMD > + * > + * unmap_page() > + * shrink_page_list() > + * > + * In both cases, the "page" here is the PageHead() of a THP. > + * > + * If the page is not a PMD mapped huge page, e.g. after mremap(), it > + * is not necessary to split it. > + */ > + if (page && !IS_ALIGNED(address, HPAGE_PMD_SIZE)) > + return; Repeating 75% of it as comments doesn't make it any less confusing. And it feels like we're digging a pothole for someone to fall into later. Why not make it make sense ... if (page && !IS_ALIGNED(address, page_size(page)) return;