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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF82DC54E58 for ; Tue, 12 Mar 2024 14:20:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0A63C8D004E; Tue, 12 Mar 2024 10:20:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0521A8D0017; Tue, 12 Mar 2024 10:20:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E34F18D004E; Tue, 12 Mar 2024 10:20:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id D0E408D0017 for ; Tue, 12 Mar 2024 10:20:04 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6422380C94 for ; Tue, 12 Mar 2024 14:20:04 +0000 (UTC) X-FDA: 81888596328.22.B481FCF Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 8DD1B18001E for ; Tue, 12 Mar 2024 14:20:02 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CUbazpkA; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710253202; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=l/F1ZKWhMDUisBwzFqHOzTQVBfOlCsMKFxt2AA8pr80=; b=OX2KkdsrwfvhlrfLwMSf3IFEW+IN5APoMTNiXzLXyRQ0IScRJklOhqAklOVHzKJBd+vmLW kiH9PIuNsz6sZbZmdGMafnFn9yuphH4JAEI0DLAJO6gkapha/ANmGs6UiGZwafhVBZR8Zo DixrKeoGuHM0av1tFMr2Tv+m3KJR+AE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710253202; a=rsa-sha256; cv=none; b=EMNau4tPnNdto1JvxnrDX2g0jWfr6EJrBuuULvoce+H15cMJ4lzfrCRnzoRTCdiYpQY2Uc 8iZVchLCWERRHD6tiyMdBAhauEQu+35atw8WUAjXFj5j80plYsxpkZkP6yhcxu0jU3Y3M4 bAHD+dLUHqop9JBIsXWBYP8jwXWqyuE= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=CUbazpkA; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=l/F1ZKWhMDUisBwzFqHOzTQVBfOlCsMKFxt2AA8pr80=; b=CUbazpkAh/aPR8nK6maOby3BVR 3t/HoxMdqjrqrtCfSou1QGgAIkH73ejMHp78BvGZLlz0dhB9tvWWq2+6mlUPaIUpLLmoHPACgD9vl HuLfr0PC5lWRaBIPUx6GxNuqmThUhORGHz8MH3neAKyEVxsvXVbfdDcNIDCU2ZWaPAINOsH5r2IUf unDcl9P3HG0rR0zfPaR5kkt4EB7ZnEbvDYpjHFiGcNjChuAbHlvg9YuHjPkUtttSHDpt2wLkzPcAe rWn1UNCKgE+seH2C/0OhezrD5Lmn38gknYccbfQUWx4JXgB5ZV2XQ3BJoeBnAF9XyTPZjvSYMyVOo JQ61ui3g==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rk2yz-00000003Bxt-46V7; Tue, 12 Mar 2024 14:19:58 +0000 Date: Tue, 12 Mar 2024 14:19:57 +0000 From: Matthew Wilcox To: Zi Yan Cc: linux-mm@kvack.org, Andrew Morton , Yang Shi , Huang Ying , "\"Kirill A . Shutemov\"" , Ryan Roberts , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/migrate: put dest folio on deferred split list if source was there. Message-ID: References: <20240311195848.135067-1-zi.yan@sent.com> <74AF044A-A14A-4C66-A019-70F8F138A9AB@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <74AF044A-A14A-4C66-A019-70F8F138A9AB@nvidia.com> X-Stat-Signature: azosm8pswyaq9uzs5meemyc33tzixhce X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 8DD1B18001E X-Rspam-User: X-HE-Tag: 1710253202-961371 X-HE-Meta: U2FsdGVkX18zRdjcxVwxExkT9l9+88H374E5Kg03TKWAajuouDfIz3F+b04Nec/vlkIDnd2y7RSs9KR6URr+5Hqx2TNxmj+Eq4ZrRErKOvev5Uw72GizOa1UbHoFiLKJrtFVETBMoExnIrsvjAozocGEKlCB6IwAywdEVv58CmDawKsXSCNAZuvQ4xVRoR5dv3Z2GWTciv6/tt48Q+lsX2LkaTU8EROiIrF9cbaVvD4LCnfN7oIeSSQ8B7S8k6JqK7u7It90QjOIi2SLKr1QOWffozPpJkbAs94vojHCRYjMukIdK9TmxVR9oLTOvaKPThAdy2k2OrdPt3jo2kTgcBPYMccuykIuZRpLLvhnznwGgGP21XLiAweKnlovVBC49tRHekoTbwxifpHX2MBc1yvUqVT3GPM4XL9i3kNVUmk7Kp88kWt9I2bEGbwk3U9n3T7FQjGKbvu2+AB3HRv+29EBSsCXS9PW+pf6A+V6ZBU084v+nwpoIrf8rlF9iWq0ZB+6DLTKOPV0Yz53RNRcBvsQu9NQGncBbnqjjujG/GHx4NO7fASGFSAIbakxuHicIXxQQZ7kQPSp8Svvo5UZakxUubOPDTNa5BN6GoOPJ6gdacOUFvDbBqMSEvLE7ABTzRFC84rd7gkrDJOAz3tYkQ92SVTmCpQALe6fjSDMUkzSCNa3gn7SrNNTDZPMGPba8j3d3nE3QCo4S+P7700n3vm47OB6dRNp+WbMmn9ZrHCMJKZsp3DHvYA0JztqxDa+F09mRBR5Mqd5O8l52d5lYezWqch1veZAFd8z3isccYIa+dNH9f3PyUsA6yHesnJR6jAcukNjLpfgz4BuFbtvq+VKt2Ez07vMMsfXhFXYmGT+m1R/jBuOQLmiB8ZA1zlbseoBr8EpIRZoF5GTVjQ6Xv/N5FGacjikGsEHQ7DtfgIFe9Z+6DgMlAKVnr/OYoqZ78DNsVTNtqLdptDHA0Y 4b1uT9BX UbGrLHioOh2uix2OIgdKioRxxVt74ZVQZ5JlkzvXzBlmzu/Npan/h1QIFl3F7QScKK1h43+CFOreymfogSZPN+SNxDRMoY/sLMCwK73OdB7NS+HhgtEhhrkbVaOOvkPyY4CusEa+GQgyhIRb+W8mTHOHo8z7XN0kfcBQ55TrvHHkln2J5fo828NIAKYPuA/s5y7WQ8R8RgyrXz/5xkmW8xRNMPs/0KwhDeG10zdXqZTajpCJ/ruMDEBpzISq84ra9w8SY 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: List-Subscribe: List-Unsubscribe: On Tue, Mar 12, 2024 at 10:13:16AM -0400, Zi Yan wrote: > On 11 Mar 2024, at 23:45, Matthew Wilcox wrote: > > Much more important: You're doing this with a positive refcount, which > > breaks the (undocumented) logic in deferred_split_scan() that a folio > > with a positive refcount will not be removed from the list. > > What is the issue here? I thought as long as the split_queue_lock is held, > it should be OK to manipulate the list. I just worked this out yesterday: https://lore.kernel.org/linux-mm/Ze9EFdFLXQEUVtKl@casper.infradead.org/ (the last chunk, starting with Ryan asking me "what about the first bug you found") > > Maximally important: Wer shouldn't be doing any of this! This folio is > > on the deferred split list. We shouldn't be migrating it as a single > > entity; we should be splitting it now that we're in a context where we > > can do the right thing and split it. Documentation/mm/transhuge.rst > > is clear that we don't split it straight away due to locking context. > > Splitting it on migration is clearly the right thing to do. > > > > If splitting fails, we should just fail the migration; splitting fails > > due to excess references, and if the source folio has excess references, > > then migration would fail too. > > You are suggesting: > 1. checking if the folio is on deferred split list or not > 2. if yes, split the folio > 3. if split fails, fail the migration as well. > > It sounds reasonable to me. The split folios should be migrated since > the before-split folio wants to be migrated. This split is not because > no new page cannot be allocated, thus the split folios should go > into ret_folios list instead of split_folios list. Yes, I'm happy for the split folios to be migrated. Bonus points if you want to figure out what order to split the folio to ;-) I don't think it's critical.