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 00147C5478C for ; Thu, 22 Feb 2024 21:32:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E2F26B007E; Thu, 22 Feb 2024 16:32:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4931B6B0081; Thu, 22 Feb 2024 16:32:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30C736B0082; Thu, 22 Feb 2024 16:32:19 -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 1F0656B007E for ; Thu, 22 Feb 2024 16:32:19 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C098D140F9E for ; Thu, 22 Feb 2024 21:32:16 +0000 (UTC) X-FDA: 81820738272.09.3A6C4C8 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf05.hostedemail.com (Postfix) with ESMTP id 8324D10000B for ; Thu, 22 Feb 2024 21:32:14 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=kDf189rS; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=kDf189rS; dmarc=none; spf=pass (imf05.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708637534; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=c4dJOBkFLnxSfVfNOF9l/CCf3u4xOydj32a58ss033A=; b=FXs7nRTvEUxBR+wkdB1RlnuJ0X7D7IIrQt9hW192H63I4e4MbOC43d0D0r90D3HOX3SFrV jUUrF/ca6ev5s7717skgEuyyQwJyZerEVWm3g2ADfHQ4pUsvHlrJvE/fY768krgXRAm64E QqjsM+4/RK0zKwr73/39wXoSMuFRZUg= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=kDf189rS; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=kDf189rS; dmarc=none; spf=pass (imf05.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708637534; a=rsa-sha256; cv=none; b=yc0hnojjfHRrycYXjwqBPi1JEpUCeki89+btdolK7m24Qu7M2EGqXxWN8NCQu1JoQLtKBZ Px+rkuR3THl/wARyyZvylhdnY/lM4xDgSyPFkf1WVl0LACviV88DsaDugjokPLIdE3pi0O PBfx15m86DpfGX9LBC+aoOL8qcHTnDQ= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [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 B199E1F792; Thu, 22 Feb 2024 21:32:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708637532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4dJOBkFLnxSfVfNOF9l/CCf3u4xOydj32a58ss033A=; b=Hz2uvLbwv3ySBAjtMwkbTlQTdX7wPSRyGHjLq60rqYcQW7V2tlpxkwcCt82iFjAa7yLg8V RswXjXVsG2695EN0deDToDYPUqw96mBljD+4YMrMAeG8g30n2qgcr4X6kbPFCCHTBS2MTj pJf7uajW41VxcnJ/Ifl1tLTzwXebM/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708637532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4dJOBkFLnxSfVfNOF9l/CCf3u4xOydj32a58ss033A=; b=kDf189rSbTDbyB9qlHlOiIuNgW9VbqNhcMeHK99WXfYncNrUhEHGTuNFVBho8OjE8Jnxk4 E0Fmqb2XwF6s8LDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708637532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4dJOBkFLnxSfVfNOF9l/CCf3u4xOydj32a58ss033A=; b=Hz2uvLbwv3ySBAjtMwkbTlQTdX7wPSRyGHjLq60rqYcQW7V2tlpxkwcCt82iFjAa7yLg8V RswXjXVsG2695EN0deDToDYPUqw96mBljD+4YMrMAeG8g30n2qgcr4X6kbPFCCHTBS2MTj pJf7uajW41VxcnJ/Ifl1tLTzwXebM/o= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708637532; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=c4dJOBkFLnxSfVfNOF9l/CCf3u4xOydj32a58ss033A=; b=kDf189rSbTDbyB9qlHlOiIuNgW9VbqNhcMeHK99WXfYncNrUhEHGTuNFVBho8OjE8Jnxk4 E0Fmqb2XwF6s8LDQ== 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 8D3BF13A8C; Thu, 22 Feb 2024 21:32:12 +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 9oD+IVy912ViLQAAD6G6ig (envelope-from ); Thu, 22 Feb 2024 21:32:12 +0000 Message-ID: Date: Thu, 22 Feb 2024 22:32:12 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm, mmap: fix vma_merge() case 7 with vma_ops->close Content-Language: en-US From: Vlastimil Babka To: "Liam R. Howlett" , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Lorenzo Stoakes , Michal Hocko , stable@vger.kernel.org References: <20240222165549.32753-2-vbabka@suse.cz> <20240222185642.rmnp76oquu5wfo6c@revolver> <20240222192746.cb65qvtmhaikfeko@revolver> <18565605-7f68-4950-b66f-496c1f3c393b@suse.cz> In-Reply-To: <18565605-7f68-4950-b66f-496c1f3c393b@suse.cz> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 8324D10000B X-Stat-Signature: ybxd7gc6cf7r8oroeac6ttiihwmjtk5q X-Rspam-User: X-HE-Tag: 1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@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 2/22/24 22:19, Vlastimil Babka wrote: > On 2/22/24 20:27, Liam R. Howlett wrote: >> * Liam R. Howlett [240222 13:56]: >>> * Vlastimil Babka [240222 11:56]: >>> This separates the check for potentially merging previous to a later >>> failure case. Would it be better to check: >>> if (curr && curr->vm_ops && curr->vm_ops->close) >>> >>> and not set merge_prev = true, ie we cannot merge with the predecessor? > > Good suggestion, thanks! Or actually as Lorenzo informed me, it would affect case 5 as well and we don't want that. And special casing 5 vs 7 that early would be ugly again. So I'll just do the code dedup Lorenzo suggested... >>> That way we would exit as merge_prev == false. >>> >>> We would have the added benefit of not having to look at merge_prev & >>> merge_next case with this vm_ops->close in mind (case 1 and 6).. because >>> I'm pretty sure we can currently get to case 6 in this way: >>> >>> merge_prev = true >>> check for merge_next.. can_vma_merge_before(next...); >>> is_mergeable_vma(next.... , true); >>> if (true && next->vm_ops && next->vm_ops->close) /* Fine for next.. */ >>> >>> Remove curr by case 6 without checking curr->vm_ops && >>> curr->vm_ops->close >>> >>> If I am correct, then are we blaming the right commit? > > It was bisected with no nondeterminism in the test, so yeah. > >> I am not correct. >> The file check will ensure the same ops, so the file and ops must match. >> As long as both are checked on one VMA then it will work as required. > > Right, otherwise we would have bigger issues even before the buggy commit, > we were never checking curr's vma_ops before. > >>> >>> Perhaps we should just fail earlier when we find a curr with the close >>> ops? >> >> I'd rather fail earlier, but it's not a big deal. > > Your suggestion will indeed result in a nicer and more obvious code, so will > do, thanks! > >>> >>> > } else { /* case 5 */ >>> > + err = dup_anon_vma(prev, curr, &anon_dup); >>> > adjust = curr; >>> > adj_start = (end - curr->vm_start); >>> > } >>> > -- >>> > 2.43.1 >>> > >