From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16BF1C5DF62 for ; Tue, 5 Nov 2019 18:22:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C182921929 for ; Tue, 5 Nov 2019 18:22:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="nlvsZjH1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C182921929 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5AA366B000E; Tue, 5 Nov 2019 13:22:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5814F6B0010; Tue, 5 Nov 2019 13:22:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 497096B0266; Tue, 5 Nov 2019 13:22:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 31FFE6B000E for ; Tue, 5 Nov 2019 13:22:15 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id D9D948249980 for ; Tue, 5 Nov 2019 18:22:14 +0000 (UTC) X-FDA: 76123043388.20.cub05_1385bcdcc4924 X-HE-Tag: cub05_1385bcdcc4924 X-Filterd-Recvd-Size: 5641 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 5 Nov 2019 18:22:14 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id e2so22052490qkn.5 for ; Tue, 05 Nov 2019 10:22:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=pnwArkk6ewZsFBfzlCm3QSvIZcXfQdL2gI9zc05CV1E=; b=nlvsZjH1/v7T7M6TqgkCioCKmz1lID0W8fR+qzL+g/Xn3iWW1er+tjFVk9Gs9AP7dH ivEVfwM0ScPftyQepjpAECysvrOUJmwlSkPPqoL+SDeEXcKZ+fD+cAGmu1N0ws03mGmJ 0Ix/asaCYyEIXt6+6bZ4X6q4F5jZzwoUPq1dGMVTjfKrwYzuHPMor6XGh7TjQj90Y5Xn 5mqVt3wklr2TrMksiyqGLFvzKRCN6ihL3NmJnWov4k+0hy4qTaj2gQhuqOa+h7CdHJD3 D83ltspXhmYuxNUYcBomVDahfBgFTsaTxWM6eaa6xBEeGagAsLvgX3VH6lxYeGvYyQID 3Jcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=pnwArkk6ewZsFBfzlCm3QSvIZcXfQdL2gI9zc05CV1E=; b=lvV1xkjpCg2EXkkjjz4jywAHKHBO3OeyXsHQLLfpbDJYVin+r8I5l9oH5n8D+S3LnD mnReKKcJF2Ts1oK8kAqMbPYBVt0FcNmI+9i/DTfe95iGgsu72lvIr4pD3DlqvgP6JPmf c+wwG+4tNHj4nRW5f29yDkBcfLWhbFcsa/REQA7HuZtrBihe/DCPhq9/4K1QTFZwwl9q oNxniIoCijnbbDFAxBbrTDfaGsGr094TDshKssqJ5iyvM2uZZXBp3/1XxKPU4PT1y6g0 zjfYQFmpzlDITa6w3evUxjjinIyzOwb+KYKi9I7e5xttHo5rwlUjyY5R/uOO+rq2IvdL K9qw== X-Gm-Message-State: APjAAAVHTiY6+ShGSRip1aHhTCVuAn/alRjasR+8QSc8jz7vg2qorIJ7 neqUMgfCxH2d9H8s0q1l0yHmeg== X-Google-Smtp-Source: APXvYqzTE2dK5t9yErXB0WIlCJJUNmO9NqBx8CY3gyQ9my8nFV2bmkgGmd/egZlpvBU6xej+4vPoCg== X-Received: by 2002:a05:620a:20de:: with SMTP id f30mr15185617qka.310.1572978133186; Tue, 05 Nov 2019 10:22:13 -0800 (PST) Received: from localhost ([2620:10d:c091:500::5685]) by smtp.gmail.com with ESMTPSA id o3sm14050216qta.3.2019.11.05.10.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Nov 2019 10:22:12 -0800 (PST) Date: Tue, 5 Nov 2019 13:22:11 -0500 From: Johannes Weiner To: Vlastimil Babka Cc: snazy@snazy.de, Michal Hocko , Josef Bacik , Jan Kara , "Kirill A. Shutemov" , Randy Dunlap , linux-kernel@vger.kernel.org, Linux MM , Andrew Morton , "Potyra, Stefan" Subject: Re: mlockall(MCL_CURRENT) blocking infinitely Message-ID: <20191105182211.GA33242@cmpxchg.org> References: <20191025120505.GG17610@dhcp22.suse.cz> <20191025121104.GH17610@dhcp22.suse.cz> <20191025132700.GJ17610@dhcp22.suse.cz> <707b72c6dac76c534dcce60830fa300c44f53404.camel@gmx.de> <20191025135749.GK17610@dhcp22.suse.cz> <20191025140029.GL17610@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Nov 05, 2019 at 04:28:21PM +0100, Vlastimil Babka wrote: > On 11/5/19 2:23 PM, Robert Stupp wrote: > > "git bisect" led to a result. > > > > The offending merge commit is f91f2ee54a21404fbc633550e99d69d14c2478f2 > > "Merge branch 'akpm' (rest of patches from Andrew)". > > > > The first bad commit in the merged series of commits is > > https://github.com/torvalds/linux/commit/6b4c9f4469819a0c1a38a0a4541337e0f9bf6c11 > > . a75d4c33377277b6034dd1e2663bce444f952c14, the commit before 6b4c9f44, > > is good. > > Ah, great you could bisect this. CCing people from the commit > 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operations") Judging from Robert's stack captures, the task is not hung but busy-looping in __mm_populate(). AFAICS, the only way this can occur is if populate_vma_page_range() returns 0 and we don't advance the iteration position (if it returned an error, we wouldn't reset nend and move on to the next vma as ignore_errors is 1 for mlockall.) populate_vma_page_range() returns 0 when the first page is not found and faultin_page() returns -EBUSY (if it were processing pages, or if the error from faultin_page() would be a different one, we would return the number of pages processed or -error). faultin_page() returns -EBUSY when VM_FAULT_RETRY is set, i.e. we dropped the mmap_sem in order to initiate IO and require a retry. That is consistent with the bisect result (new VM_FAULT_RETRY conditions). At this point, regular page fault would retry with FAULT_FLAG_TRIED to indicate that the mmap_sem cannot be dropped a second time. But this mlock path doesn't set that flag and we can loop repeatedly. That is something we probably need to fix with a FOLL_TRIED somewhere. What I don't quite understand yet is why the fault path doesn't make progress eventually. We must drop the mmap_sem without changing the state in any way. How can we keep looping on the same page?