Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp605481rdb; Thu, 22 Feb 2024 13:32:26 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUtq1d4tlMIIwtufc0ftpIOCL9XcOZi8ph6lWZqWixzz1GQaP3vnqK/G7a0XKibbzgRdZ27ufCwwMYNtC5HHqkEBpVxcp8SIJGGCYeaVg== X-Google-Smtp-Source: AGHT+IHMvVmohetdJgwTyDQX7SpB4UossLxxG0/NcLEq7z9+J6/W94xn7MT8uluujweOTd9e8qdQ X-Received: by 2002:a17:906:448f:b0:a3f:4516:ecf2 with SMTP id y15-20020a170906448f00b00a3f4516ecf2mr53750ejo.32.1708637546001; Thu, 22 Feb 2024 13:32:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708637545; cv=pass; d=google.com; s=arc-20160816; b=FG6GK7HQiXrjPnSdKHbrRR+Ylms8p3LmAXxNisDglOxOr5sfx92BptNlcFeq/EV5VN a+iJsTwoX3S11gQYNytdjBUuBIdlMeqdCpTqV7oGKhtSETS7Em6xPr7SyPpQ1z5vQqTV Ezdx5NG01TQhPYE8s9ApPf5hJERszKmqv23FyKasJmLq0ypk2rHoYhrxq4fPXDTyJyKi XXXXMPriO7HL6iBQ2kvITbIMvRR/8+BoQ3RutTMSYH+dZvUOzyoRIAxw+o0Vv/rcM77Q 8/aQGP7VEee8OARFRTxBrK5r2ja4mu4YuhVyErHdNpHO02Y68b6UYhg9tHt5uuGXXSy+ +BDg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=c4dJOBkFLnxSfVfNOF9l/CCf3u4xOydj32a58ss033A=; fh=di/ouMuHkQX7tfFSUN62/3suNSqq/XmEmZho1zS11lQ=; b=LLrmTj2caCY3DeT0CQ1ZCKQ3EEWnkLv7VtxNrlaG6z9pGhkYNDv6tjsAzm837MJstf HXpWELL3xB6UW8qmOW9ZgK19rHDBKioS385FRu4xFWmskO92g2CTv8UbFBHYQwL5nPhz M4br1gq37lXc/C0L933SHrqq4+ZH91kNC2mhlc3SovTEvON2tbPrGQfj0uulRqrlMqHp 6MVc6UriIOiz2zC/ilqJ1gxh4/XkmCt19XtYanCanciP9bKKc5RczjB6SQQkCpW9DHSR 9u49ujPkpibs1iE6UqX9aMNafHbZ0SWmhaCizCjisIBBs88QucSen+le2DiaaHePNZZu Aw9g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-77405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77405-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h6-20020a17090634c600b00a3ea9514075si3925544ejb.317.2024.02.22.13.32.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 13:32:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=Hz2uvLbw; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-77405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77405-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 931791F28FEE for ; Thu, 22 Feb 2024 21:32:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5291C73F38; Thu, 22 Feb 2024 21:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Hz2uvLbw"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="kDf189rS"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="Hz2uvLbw"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="kDf189rS" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9692571738; Thu, 22 Feb 2024 21:32:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708637536; cv=none; b=szTQD/2w3qmFZUsbvdOznTeCy6asNqJUrzrLEub5GFzstSuDVR6DCJtBWLrQq3/wI9KLtKW8nHsycDcnBPGXO78sYDiJuvdOYu2ZIJhMl0sMMeO7d/pqpxn2nGWMZzFI2cnP6k6wEHRXd2S9G1vaQdRmrlBMUt0Mw4kaouiEe0A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708637536; c=relaxed/simple; bh=AWl+DXGsKjgrNy+G5SN3TUq9VMTt8GW/MbSwwKglgPE=; h=Message-ID:Date:MIME-Version:Subject:From:To:References: In-Reply-To:Content-Type; b=ktsQ0QUZjZ3hsvRA7ulfg/SZGdDW0o1ABRYyJyq1VG6uuHDORc8uqsCWUMtqnI8wh/0063eDu2iWHux7fF4MSb5+PG8xD6OhG2pBSyc6KyYPDoSIyMZP+8P+G0uGuWu9Gn9D+1VyERMa807eSM8As1XyKdFyytF6tlFRxwTAAWk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Hz2uvLbw; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=kDf189rS; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=Hz2uvLbw; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=kDf189rS; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -4.29 X-Spamd-Result: default: False [-4.29 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; BAYES_HAM(-3.00)[100.00%]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; DBL_BLOCKED_OPENRESOLVER(0.00)[oracle.com:email,suse.cz:email]; FREEMAIL_TO(0.00)[Oracle.com,linux-foundation.org,kvack.org,vger.kernel.org,gmail.com,suse.com]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Flag: NO 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 >>> > >