Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3661338pxj; Tue, 1 Jun 2021 10:13:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJZNufOuR6AthWCes9B6xDEev8hfJ0RBfBGjjG5yPBQPQy8QU/rj+x4dwF/deSnRGDjcZn X-Received: by 2002:a6b:ec03:: with SMTP id c3mr22029769ioh.103.1622567599542; Tue, 01 Jun 2021 10:13:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622567599; cv=none; d=google.com; s=arc-20160816; b=tm9zbg+UAvpgpiUCrwb/q6uU0SbA+7y6cPaW+16r8k6ZNXC0bxQvLlnG2YlEXMtsZN L2kIyj2DL/RXL79JfudPTA8fe9rwYh5gmGmH+FtwEemdWNaHz1JDNt7aYtQuOQ47r+fL q8kmPmgipVMcSSn1H9qjkbv5h0Qg+brniF1XK1GSu3t769USj5tEizphT4UYbGdUEXHH ILstddAIFanEuqiGbcq2xftgbd+MzGPEqtfXaKtColnG/dkOMkgPGylsQDDw8W784AQq I2EVAw/yEAjB5mLTSiqk31ceYmHJwE0moNdUYy26ITLk68MiJIffpG+YVxGVGksfrNOx BrjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NPf5x5gUIVGWbZsyHctHSrCy7CgzrGDQAuJK0Pfsp3Y=; b=OveKaRY3z2bRyxKHM8vBmv6pa4tskSZJGO/CQDaChru5Cr/S5kcEyxZd7N8Xd2lZhh xLWH/YCIivcFk6yAaZ0EsMBv2Z+wHtdwK7jWJTGM0osUGKYlhy7F9a7BB0A6lVNgahZy 25kN7E30muIJUhJnwt+SL0y0RUiM75KxVuWsBv6zY5aeaRPQD839WgIaQPZepSVYul/f aeUchd7IvafXkCCGsAM2I+ru9g1VyO+TvFrhtbo5sy6ZCb3OFwQyFKDJBpTvYAtIgbwf g6VsH75TJy/vyWtcHNsK/KO6lbnHNDKOBJVr/huuKQw7cGEMrL6RAkfngCr5FEAg1GX5 aPjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=WlE4PI42; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s6si4411168iln.106.2021.06.01.10.13.06; Tue, 01 Jun 2021 10:13:19 -0700 (PDT) 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; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=WlE4PI42; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233871AbhFARNC (ORCPT + 99 others); Tue, 1 Jun 2021 13:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231918AbhFARNB (ORCPT ); Tue, 1 Jun 2021 13:13:01 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E304C061574 for ; Tue, 1 Jun 2021 10:11:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=NPf5x5gUIVGWbZsyHctHSrCy7CgzrGDQAuJK0Pfsp3Y=; b=WlE4PI42i6Y6aDb/sYuOCvJ1gY RfLnhnWbAfBudWuf90hOxdqLJhVGrsOBAxt3Mgi/HNcUps/2Ki5MDTRa6FSqnfnH6uGhQb9a+eXfi 6D6szn2br23LVELB59uzFnC3B6jYRDoIU+VM8xIeNFkkGkEaHyeV7NlGZTTcAbc5lbbyKbgDU6QpC RrEtd2GgWcxzRmoWJfDYAU9vyTS+4R9kjyx+I5fBeR6KAyXmfIVLBrCcuFZBhCvl0lxz3LebseLXG zNNI5twSQdFutcu+ImqvVCTTTJnftTiWA/Q+LglDxAiM4YWs7hT/MCxhVXr4KsMBJLaZKma1Srch+ TtlFl8aQ==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lo7uy-00AEsQ-Pn; Tue, 01 Jun 2021 17:11:06 +0000 Date: Tue, 1 Jun 2021 18:11:04 +0100 From: Matthew Wilcox To: Hugh Dickins Cc: Xu Yu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, gavin.dg@linux.alibaba.com, Greg Thelen , Wei Xu , Nicholas Piggin , Vlastimil Babka Subject: Re: [PATCH] mm, thp: relax migration wait when failed to get tail page Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 01, 2021 at 09:55:56AM -0700, Hugh Dickins wrote: > On Wed, 2 Jun 2021, Xu Yu wrote: > > > We notice that hung task happens in a conner but practical scenario when > > CONFIG_PREEMPT_NONE is enabled, as follows. > > > > Process 0 Process 1 Process 2..Inf > > split_huge_page_to_list > > unmap_page > > split_huge_pmd_address > > __migration_entry_wait(head) > > __migration_entry_wait(tail) > > remap_page (roll back) > > remove_migration_ptes > > rmap_walk_anon > > cond_resched > > > > Where __migration_entry_wait(tail) is occurred in kernel space, e.g., > > copy_to_user, which will immediately fault again without rescheduling, > > and thus occupy the cpu fully. > > > > When there are too many processes performing __migration_entry_wait on > > tail page, remap_page will never be done after cond_resched. > > > > This relaxes __migration_entry_wait on tail page, thus gives remap_page > > a chance to complete. > > > > Signed-off-by: Gang Deng > > Signed-off-by: Xu Yu > > Well caught: you're absolutely right that there's a bug there. > But isn't cond_resched() just papering over the real bug, and > what it should do is a "page = compound_head(page);" before the > get_page_unless_zero()? How does that work out in your testing? You do realise you're strengthening my case for folios by suggesting that, don't you? ;-) I was going to suggest that it won't make any difference because the page reference count is frozen, but the freezing happens after the call to unmap_page(), so it may make a difference.