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 9ED26C4829E for ; Thu, 15 Feb 2024 20:03:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 35DA76B0085; Thu, 15 Feb 2024 15:03:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 30DA46B0092; Thu, 15 Feb 2024 15:03:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AEBB6B008C; Thu, 15 Feb 2024 15:03:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 028B68D0001 for ; Thu, 15 Feb 2024 15:03:03 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6887F80C3B for ; Thu, 15 Feb 2024 20:03:02 +0000 (UTC) X-FDA: 81795111804.12.989B6A8 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf04.hostedemail.com (Postfix) with ESMTP id CAFB540016 for ; Thu, 15 Feb 2024 20:02:58 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="ZI/jCPPv"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4AQXmCFX; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="ZI/jCPPv"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4AQXmCFX; spf=pass (imf04.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708027379; a=rsa-sha256; cv=none; b=plLSdxOrGVIul7MCuSzYrrAWMrFitN1gG2BP16yi5fkOW0vE8M5WVwIIUBI6T1COUCRMyg 5hGV12btr9bDgvUF5e8+EGi1XiIcG9JrqBHRG7NR7ZPY6AgImz45x+HJqcF7W5BLfDNJ+I SMiQkx8aFskXwwhrINeT7EMKk+yxr0o= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="ZI/jCPPv"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4AQXmCFX; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="ZI/jCPPv"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=4AQXmCFX; spf=pass (imf04.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708027379; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=PERVCXAFrMhan0F9FQFEGlBIXfFbcTjGpAr7PL6j+Xo=; b=O6zCndOHcxk88d+/lXDRlYBZpB+u/pYUEPbI9bj0cagFkFLaW+5Spq9SbnpoSFvEFevsei CwjqzsP+NrBjnFdF9vX9dXLvjgT9/JM7t7RRlvCAFbNyVtpbiF8/NayLh+0X2ECYm2IMn9 sJpnBhusclI+1KILXEZyL/QjPGAlHO4= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 85FF51F8D9; Thu, 15 Feb 2024 20:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708027376; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PERVCXAFrMhan0F9FQFEGlBIXfFbcTjGpAr7PL6j+Xo=; b=ZI/jCPPvM7bk89EFGpEWJCJNroklydChgjcBal+t9/zyol+pSh+Puc3wsVBpLgJAarDI80 RRJ44XPgQNej6nM4bl25j0owukI4D9O0hAzy1DgmgNKfSA3MbFDGiTKbYUf82rhJM7nX5u vOeT3dl5GCVHd6dmMmmge7HGas8l7Jc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708027376; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PERVCXAFrMhan0F9FQFEGlBIXfFbcTjGpAr7PL6j+Xo=; b=4AQXmCFXDnP3C93B/dAbH8Kz27Ko65oJohDbyLX07yACNs3eaOwaWxcUmrjF+MDL8//hCs IW2DGSEIqK/s8OBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708027376; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PERVCXAFrMhan0F9FQFEGlBIXfFbcTjGpAr7PL6j+Xo=; b=ZI/jCPPvM7bk89EFGpEWJCJNroklydChgjcBal+t9/zyol+pSh+Puc3wsVBpLgJAarDI80 RRJ44XPgQNej6nM4bl25j0owukI4D9O0hAzy1DgmgNKfSA3MbFDGiTKbYUf82rhJM7nX5u vOeT3dl5GCVHd6dmMmmge7HGas8l7Jc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708027376; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PERVCXAFrMhan0F9FQFEGlBIXfFbcTjGpAr7PL6j+Xo=; b=4AQXmCFXDnP3C93B/dAbH8Kz27Ko65oJohDbyLX07yACNs3eaOwaWxcUmrjF+MDL8//hCs IW2DGSEIqK/s8OBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 2C6DE13A82; Thu, 15 Feb 2024 20:02:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id Vr7yCfBtzmVYNwAAD6G6ig (envelope-from ); Thu, 15 Feb 2024 20:02:56 +0000 Message-ID: <25a80b95-93e6-4d68-a3b1-35cd3ef9c421@suse.cz> Date: Thu, 15 Feb 2024 21:02:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 2/3] mm/compaction: add support for >0 order folio memory compaction. Content-Language: en-US To: Zi Yan Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, "Huang, Ying" , Ryan Roberts , Andrew Morton , "Matthew Wilcox (Oracle)" , David Hildenbrand , "Yin, Fengwei" , Yu Zhao , "Kirill A . Shutemov" , Johannes Weiner , Baolin Wang , Kemeng Shi , Mel Gorman , Rohan Puri , Mcgrof Chamberlain , Adam Manzanares , "Vishal Moola (Oracle)" References: <20240214220420.1229173-1-zi.yan@sent.com> <20240214220420.1229173-3-zi.yan@sent.com> <6a011e7f-4e21-4e31-a9a2-52cba3181337@suse.cz> From: Vlastimil Babka In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spamd-Bar: + X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CAFB540016 X-Stat-Signature: 8kanptbem87xbk8hr4p46w1zk1qtun14 X-Rspam-User: X-HE-Tag: 1708027378-37794 X-HE-Meta: U2FsdGVkX1/Gou1tr4BRK3h5625ef/75nASiXH/XaR1iSD7Wruiay1TFHvDgOzve1Z2fhl2vH+bEsMWfrXXo2yIi0ThloTxToL9VY/TED9MoYFb+thuL4MhoiMOK1npzrgrGg2iMK3xtc58P2807K4M/rdyHz7Qx38R3ZAT0IwAYFb/40AYzLxiQpoWiYUgeDV17KWUyJlfUPZ2KTPNzGwM8jfDAz/xMNfb5QW/pE5FZT+zaqWFLqOLl+ES0DuxkQFnaX/bePvfW6n6AdW0ne0kCrxam1nr4o+fkaLKisdsPkyjmvDzdsBws7zNWUthj27DZ850wiC0pz4ualjX8roIT3DOqboMLQ0VHCrrWGE+shp+pLc3VcfcFg1sfqcTPxFGr/RWewvI05FIjEM1YiPk+MJdfwO0hw0fxZdLJzuA1S9qVlxv7mxfSstzmJt2qPYLRaabDs15sqLoekZe/6peZ432M1asPut5ETQxvmLu1rQ1imugKUvpiwKDLEwT8p6IYASQEylMK+r3PPoN5XG3gL+PSt4wt3nfMabEgF3tOqvjXME/2h/oFp0qjN1zhjxOI8bM1XHXN50eyz8flkhmWnQ2NPKeTIkNjKS464VQEuFmybRU8kVor4L8fHwhsgYjJnzvP9GhHWZVnEQSpmVIdM9qkwwegsQCXW1YsD5pE6ip3jLBBYaA4oRoO+ndt7MOk/Qtpinn0QZ/Brume0kFOW/8mSi9GBZormC5g5hLpbVpeYuL07qc0y64T7R7hDjgtA5S1CNLLpYADvekFAbTuOlmbjKqLllH5U/uqvL1az8ucYxcpxbGzw8Ri6W9s4hFXxE+wWQykxiEdxVW4CcEP+PDPW3RDQtFYY1dX1DJiiOhAIuk9sfVHhQT6L+Q/qrmQFq/i7KukbV8jLktX86Af/v6pCkLrkgElsqnY5VQR7DJyu+xAJT+xTb8r0n7P9Xj4IlMBBNClsNtpeon ed5q5hJv ZJLQhcBkYslKGR91pqZTkJ3fx5ZACpipb5NVYZdyW8TeWjG43hIlljCqHkBTv1hogpinFf6EDk99TP+8wAPynhKJGc37PhIATMuVtR1YEWgZoT4uTSzhaX5VKafissAA7I1H7Uo+0+fJBTFG74pFG/rtnELEUNuQHSiahgToaolh9Ng8+wRB7WatxmkP9pgn7iNFsnhiu4vNLl76GHJlcT1hsK+OiD3Oo4Eb/Wi7t6DGC9gKXGQAAr/nzLRpy2QKyuKZhXHwRIAH0qaRmlxUUKxHqUg4IQes9HEDfhFuKN5JhPWaABESGx1oGF8Z/6TLMld8vg9Nd/Ii1me43Kv3tW6r4nQ== 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 2/15/24 18:32, Zi Yan wrote: > On 15 Feb 2024, at 11:57, Vlastimil Babka wrote: > >> On 2/14/24 23:04, Zi Yan wrote: >>> @@ -1849,10 +1857,22 @@ static struct folio *compaction_alloc(struct folio *src, unsigned long data) >>> static void compaction_free(struct folio *dst, unsigned long data) >>> { >>> struct compact_control *cc = (struct compact_control *)data; >>> + int order = folio_order(dst); >>> + struct page *page = &dst->page; >>> + >>> + if (folio_put_testzero(dst)) { >>> + free_pages_prepare_fpi_none(page, order); >>> + >>> + INIT_LIST_HEAD(&dst->lru); >> >> (is this even needed? I think the state of first parameter of list_add() is >> never expected to be in particular state?) > > There is a __list_add_valid() performing list corruption checks. Yes, but dst->lru becomes "new" in list_add() and __list_add_valid() and those never check the contents of new, i.e. new->next or new->prev. We could have done list_del(&dst->lru) which puts poison values there and then a list_add() is fine. So dst->lru does not need the init, it's just confusing. Init is for the list's list_head, not for the list entry. >>> >>> - list_add(&dst->lru, &cc->freepages); >>> - cc->nr_freepages++; >>> - cc->nr_migratepages += 1 << folio_order(dst); >>> + list_add(&dst->lru, &cc->freepages[order]); >>> + cc->nr_freepages += 1 << order; >>> + cc->nr_migratepages += 1 << order; >> >> Hm actually this increment of nr_migratepages should happen even if we lost >> the free page. > > Because compaction_free() indicates the page is not migrated and nr_migratepages > should be increased regardless. Yes. > Will fix it. Thanks. > >>> + } >>> + /* >>> + * someone else has referenced the page, we cannot take it back to our >>> + * free list. >>> + */ >>> } > > > -- > Best Regards, > Yan, Zi