Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp600117rdb; Thu, 22 Feb 2024 13:20:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUpfmDANW9aJjd8GeMiswotSgBjExjRpZt92GR5M8atIPwe5H5PAXa4aFEqbsNYxLW/QA4SdUpigv8D/VS4uyDUrXx4Z7Dlx0Wcc4yr6g== X-Google-Smtp-Source: AGHT+IFMI1TqZ8UIENlFosYbLhi/vQvrSO3pZtTiJt8Q/FYHQtaOfEcM+AIaW3box6csGQnDs+Yd X-Received: by 2002:a05:620a:b87:b0:787:5177:ebbb with SMTP id k7-20020a05620a0b8700b007875177ebbbmr288090qkh.28.1708636804247; Thu, 22 Feb 2024 13:20:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708636804; cv=pass; d=google.com; s=arc-20160816; b=vab1NDQKGXX8M6q6/Vrx8vLfBScHsn8xafzN7qTdRjPy5kTkYwrYKhf+vU2K+G27Fl AujXqCTdHxEb9rioyQMHu0R+Yt7zXQV4QRMzIez1nmPsCLN8g+m0956kvMZgCISnxfRM DdAxqUkR4IRu0DpokhYhb8lxDycG+tijhyUmO6Q5lcrX/ahr2L+5jcOYSWGTJLKJAdNw /gYA+MJwmMQRxvrbXgeyO/9jKnuwaQGgBCFaqtGK/1mJDadftjl8qS/3Xb/9PxG01osQ j3xQcYXauCT8Szfrwv5i/XraJxibhB8XHhSxikqRam25jX7oBrRsmWdkA7LYGkPb9eWU 2BTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-signature:dkim-signature:dkim-signature; bh=Nmwy2si2pJ2mNU0MlM/z5AaEWl08Athx/4vltay9xWM=; fh=di/ouMuHkQX7tfFSUN62/3suNSqq/XmEmZho1zS11lQ=; b=xZUtfH1WzRTFt2sx8NkPGDzU2h2J5941RLHhjqmXHyVWAw0mNLPTear5unFDX5qBse OZTxf6cUT7JdBEQk3MhV6yg9tcoxp+lL0lHPtEjXs5n8cxmySetgYm5x8s/vzqVeJ8AL kBpJ0SsOjpzsjo1TSpqwhYGeKIOuXmtjLc9Wk+Pl6xUu+h/hs121F4HCM9wfqPZrUcwy 9AURSqEHR+5GnmV9lt7owWD8JktaLXumRD4AYuLyJx0XGs7vsvUVelym/ChYGs5YeR8p x3t5JZecXA2j8UE5hH2s9k88kf4y2UFvzw/tecgmlatEpc7SGxo9sobWBcguBJ2iTEcL zZTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=nTH7S3Pa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=nTH7S3Pa; 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-77387-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77387-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x5-20020a05620a0ec500b00787701d133fsi7972995qkm.489.2024.02.22.13.20.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 13:20:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77387-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=nTH7S3Pa; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=nTH7S3Pa; 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-77387-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77387-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id EB9861C22F96 for ; Thu, 22 Feb 2024 21:20:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 889E373F2A; Thu, 22 Feb 2024 21:19:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="nTH7S3Pa"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="klL58VXW"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="nTH7S3Pa"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="klL58VXW" 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 C3E6914B832; Thu, 22 Feb 2024 21:19:54 +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=1708636796; cv=none; b=thjx5Drd4ZrlytC5DLcSBhsGnu7Ixzh9kLrlIKBPhWYW0GvHJW3ZDcKEXJV8wblrI8ov9rCbMoM43pVZYjbrehLsbarLlQr3ZzIevd5jco0CUb1MOlpKJnXj1Aw/6vll4Wwcugu+SjCgu/rcsqJWYZN95ohZfHQns+XXR+Va8lc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708636796; c=relaxed/simple; bh=a0WLqrpp2l3G1FiWSHQkOMJyuTQ+z8ar0GIz5jZCnIU=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=hjwGq3R/Hxb8hT7XkOfDn/9mgElaj1L/4HmyMsN2mi0sKUapQSMHfKgna0vHVSvsEKKZJFMNuwaHI9NYmkhdow+t22bbSOJMi6M9f9rI6AaoUAukyBHEeaUb60hW33OXiKkiwQhMl/cBgdDBHdiN+htDh4/TK2LdPNG4v2GJ/wM= 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=nTH7S3Pa; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=klL58VXW; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=nTH7S3Pa; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=klL58VXW; 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 [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 9F4231FBB6; Thu, 22 Feb 2024 21:19:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708636792; 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=Nmwy2si2pJ2mNU0MlM/z5AaEWl08Athx/4vltay9xWM=; b=nTH7S3PanwNm0vSUAJGfofhoWbap77NuQWPXpHbQ1p7+vVMIlw2H6L+4fv8xNbT/5bIVRP /phzpnBch87802xFXGhA3UOKXzuh7SlC2vBUXS0vISLNPddWML0M4zO+Gz7M2RIoHO02DM haUdYTIkowYrr+g/xV3yoByT2O9W+8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708636792; 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=Nmwy2si2pJ2mNU0MlM/z5AaEWl08Athx/4vltay9xWM=; b=klL58VXW0qULmuuzYQPKnVJUsqc30dJTQ/BQnFmCOK6IyMR2r2OHG7tTqCzhoo6DGh+Dxd LyCGHxjDZeogT/Aw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1708636792; 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=Nmwy2si2pJ2mNU0MlM/z5AaEWl08Athx/4vltay9xWM=; b=nTH7S3PanwNm0vSUAJGfofhoWbap77NuQWPXpHbQ1p7+vVMIlw2H6L+4fv8xNbT/5bIVRP /phzpnBch87802xFXGhA3UOKXzuh7SlC2vBUXS0vISLNPddWML0M4zO+Gz7M2RIoHO02DM haUdYTIkowYrr+g/xV3yoByT2O9W+8M= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1708636792; 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=Nmwy2si2pJ2mNU0MlM/z5AaEWl08Athx/4vltay9xWM=; b=klL58VXW0qULmuuzYQPKnVJUsqc30dJTQ/BQnFmCOK6IyMR2r2OHG7tTqCzhoo6DGh+Dxd LyCGHxjDZeogT/Aw== 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 7A69513A8C; Thu, 22 Feb 2024 21:19:52 +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 GnyhHHi612WzKgAAD6G6ig (envelope-from ); Thu, 22 Feb 2024 21:19:52 +0000 Message-ID: <18565605-7f68-4950-b66f-496c1f3c393b@suse.cz> Date: Thu, 22 Feb 2024 22:19:52 +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 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> Content-Language: en-US From: Vlastimil Babka In-Reply-To: <20240222192746.cb65qvtmhaikfeko@revolver> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Level: Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=nTH7S3Pa; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=klL58VXW X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-3.00 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; 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]; RCVD_DKIM_ARC_DNSWL_HI(-1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MX_GOOD(-0.01)[]; DKIM_TRACE(0.00)[suse.cz:+]; RCPT_COUNT_SEVEN(0.00)[7]; NEURAL_HAM_SHORT(-0.20)[-1.000]; 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_IN_DNSWL_HI(-0.50)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Score: -3.00 X-Rspamd-Queue-Id: 9F4231FBB6 X-Spam-Flag: NO 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! >> 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 >> >