Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp334855pxb; Thu, 5 Nov 2020 01:00:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcBlquemjbZ7uY0lhGosJoRE61z6JjWTzyecbgetCklXTNxBTM5VdooahZRAf3FBLJ8SK0 X-Received: by 2002:a50:d582:: with SMTP id v2mr1559059edi.218.1604566807302; Thu, 05 Nov 2020 01:00:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604566807; cv=none; d=google.com; s=arc-20160816; b=NgrweSAvMwl2JrZ640t3D2YPrTVvcJUVkVI794iQiRlNUZiPHIoED/rrPM2saiqKjQ EwBTEBTjmG11B5JCsGy4jJ1HIWu+aSUdTd2Ls+83X4yw4wFREqS7biSqTILH8N0PkTxg Q2xQrMxjoKEo7tobLUEOAj/cKaK2DaLvTMEQ8LmCw8prs54tCxhGb5WR+QtrephasJMA YP7JE30+ZX9jQfdRlApgyZVc5L+xqTcUiyfYxj/CxUAPqNv+y1evtXgZjr01k3vLcL2R kmtODWM+qu+96oFWpPEBxwI5EhuZ1gUWr1EPDrKMWLFC3ffMVOiOxbu3GSKKGQ3xH6j8 dhRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=vFUQjYwzA0aWSH8MJdP82zT9aggm0rQFH1Y7RQgZDwI=; b=xWBS9FP6e4GKdy+JJdJOBafUhn55DLl5Z2ZY/k4fYmbiNaJ4WD3UHXroWihvNe9A5Q /O7IiW6+w8t+XRxgkQgP9cMqVoMkWeltuv8KlaScZWxWh5n8mxq/lRtM8nQX2kBV9Wqj IwHSqnpc0vQhwWNF4a133ufjQxjU/WDGqosYEBAjhqqe8MJt6uI3jrFPzS8J8R3+V7j/ 2G5JR7y/2Gs+cl8rV3FBX7vtXZGBb7AduKENInjFpwrPC9jqGozFEPbhikmecbbtgmeq ml55UmFwNy4qJ6/htB7tYeEQ48ISVLhHArOWMsXXxI+HxS4uPPnwdqKdJb6JQghDYEa9 YK+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h22si660198eje.314.2020.11.05.00.59.45; Thu, 05 Nov 2020 01:00:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731311AbgKEI4w (ORCPT + 99 others); Thu, 5 Nov 2020 03:56:52 -0500 Received: from out4436.biz.mail.alibaba.com ([47.88.44.36]:56998 "EHLO out4436.biz.mail.alibaba.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730917AbgKEI41 (ORCPT ); Thu, 5 Nov 2020 03:56:27 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R181e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=23;SR=0;TI=SMTPD_---0UEJC3Fv_1604566567; Received: from aliy80.localdomain(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0UEJC3Fv_1604566567) by smtp.aliyun-inc.com(127.0.0.1); Thu, 05 Nov 2020 16:56:13 +0800 From: Alex Shi To: akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, willy@infradead.org, hannes@cmpxchg.org, lkp@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, shakeelb@google.com, iamjoonsoo.kim@lge.com, richard.weiyang@gmail.com, kirill@shutemov.name, alexander.duyck@gmail.com, rong.a.chen@intel.com, mhocko@suse.com, vdavydov.dev@gmail.com, shy828301@gmail.com Cc: "Kirill A. Shutemov" , Vlastimil Babka Subject: [PATCH v21 12/19] mm/mlock: remove lru_lock on TestClearPageMlocked Date: Thu, 5 Nov 2020 16:55:42 +0800 Message-Id: <1604566549-62481-13-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> References: <1604566549-62481-1-git-send-email-alex.shi@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the func munlock_vma_page, comments mentained lru_lock needed for serialization with split_huge_pages. But the page must be PageLocked as well as pages in split_huge_page series funcs. Thus the PageLocked is enough to serialize both funcs. Further more, Hugh Dickins pointed: before splitting in split_huge_page_to_list, the page was unmap_page() to remove pmd/ptes which protect the page from munlock. Thus, no needs to guard __split_huge_page_tail for mlock clean, just keep the lru_lock there for isolation purpose. LKP found a preempt issue on __mod_zone_page_state which need change to mod_zone_page_state. Thanks! Signed-off-by: Alex Shi Acked-by: Hugh Dickins Acked-by: Johannes Weiner Cc: Kirill A. Shutemov Cc: Vlastimil Babka Cc: Andrew Morton Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org --- mm/mlock.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index 884b1216da6a..796c726a0407 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -187,40 +187,24 @@ static void __munlock_isolation_failed(struct page *page) unsigned int munlock_vma_page(struct page *page) { int nr_pages; - pg_data_t *pgdat = page_pgdat(page); /* For try_to_munlock() and to serialize with page migration */ BUG_ON(!PageLocked(page)); - VM_BUG_ON_PAGE(PageTail(page), page); - /* - * Serialize with any parallel __split_huge_page_refcount() which - * might otherwise copy PageMlocked to part of the tail pages before - * we clear it in the head page. It also stabilizes thp_nr_pages(). - */ - spin_lock_irq(&pgdat->lru_lock); - if (!TestClearPageMlocked(page)) { /* Potentially, PTE-mapped THP: do not skip the rest PTEs */ - nr_pages = 1; - goto unlock_out; + return 0; } nr_pages = thp_nr_pages(page); - __mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages); + mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages); - if (__munlock_isolate_lru_page(page, true)) { - spin_unlock_irq(&pgdat->lru_lock); + if (!isolate_lru_page(page)) __munlock_isolated_page(page); - goto out; - } - __munlock_isolation_failed(page); - -unlock_out: - spin_unlock_irq(&pgdat->lru_lock); + else + __munlock_isolation_failed(page); -out: return nr_pages - 1; } -- 1.8.3.1