From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 C804F3CB8FF for ; Tue, 23 Jun 2026 09:42:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782207766; cv=none; b=RKCEc4byJtP8z60wRE2BZYmLpDRs/W/gmMIzKQWyju92DU0LsLAvkpKy7VXABH2nqwEzqhYA362TCyeVJKQ5ZX/r/l2HELnOw/OLke5w0MNvqj96WvPp58j0N0wT6jlvNm+e1o/JGTm5iiLGz4iZZ1Xo0GdKOPZoE6vbj+e5PHY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782207766; c=relaxed/simple; bh=B8aiSRXgNzNgIcTsqvlM+jiX5YYMrahhBOPApOswCwI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HUdWYfNaGBLL0/SIr0DOlh40/GrGbCD60d3PSmAS61DdzyJRPqkwf0kUWlI0Q3M8g3Ts32vZfSLuttuLu3Q4gUehugpuTZCp7cKmAP5OsfkDTtMsMv9g3+ncI2uJtNZ7Jws/rlJ7EApC5ptK3gWzvLj9D2qtVH+DM5eMfu5D7T4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YGHMw40j; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YGHMw40j" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-49249072f03so16358755e9.0 for ; Tue, 23 Jun 2026 02:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782207763; x=1782812563; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3SJWx7Zgz0Pyhs4JZwrYmJyYWWMlxydwzpM41quzKVA=; b=YGHMw40j4hj6TfkUnHCRzMeFQvWey1PFjYwC9WxoimkjXSyYUToNiCRRG3XizMJyVX R4ai/ZAAtQDz4f0JWVvcuKQwNrd5Txlkb06UI4Ip+E8l4eB26vkuxuFn6OwMwOYXB61O kCwX0AeABcbrjheN/oka2jvup/pAupU+T8RVm3c6KdjPN3Cw8ivsZFWQa+3luBAcmyHJ J/ccU6I5B7wsmabeYLLM2iBu+F6a7H0unq3OEVcxPr0XIQHv8J7AknumxKhEAFyiYQs6 +mqpx2Bs3bCk6AORQ3O0om6vm75JrMhz6Uyb5FEYTnIsi88xM/cBebtwCOEISqrxBiUn GWLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782207763; x=1782812563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3SJWx7Zgz0Pyhs4JZwrYmJyYWWMlxydwzpM41quzKVA=; b=sc5A1fnaBR6rlv4bUCmmdqGmMbcqPqmtClptsyv3/+ny6JgRx8M/kj+Z6GE+hwS7PX DghvkW79oYzW2w+Isn23GHZZFDSOcJqWqxlFZtCPP/iqm5jsnuRJhNaukVr6mpru9IDW I49f2nHgC5UMtwLEO27jCn++ZrdgoJ9bon49hwFghp9t4B+9WnIrVA3ufecpepy53jIk nmCsVacNEptwR0n3XK73+e2SxpF3do+Iniy66F6U+D0kuccnm2t6TL0KnSUgcN7DE8pM o+OSQ+MuYmPb/gnvWqjMg1W+KT8lV4bjd7jKXoeCcAydZrg+SG9iVVCAtuDA6dC0A2kr +WKA== X-Forwarded-Encrypted: i=1; AFNElJ9ZWI9nKMjeJs0GyhSlVgANe6lqOo+vM8NL6ffi3y5rxluJOSqzDh4ZopcsOns3ql9iS2P6g8uEl9C0XI0=@vger.kernel.org X-Gm-Message-State: AOJu0YzC+pILIVIqiS6cVXboz7APQeDSCN6R8N/V0ZGG4/MN9zY4jdbE 3G3DyB9xOyGZyn05MTNiozdzUujuHkVxGsqK8qjjWWEw9l+LhYCoSsVp X-Gm-Gg: AfdE7cmfDtxwtm1QLIXdZfCIL0NB3C+wGRtOsFqgfZA3eIDT4VJmDgoAQspU8Fp5tVS Ru7q3LQJszbTbjreO5toLQKOP3Tdr57QBiNnS79XCzd3XABvt2gPn+2o/nWU+z6B/wu3Rep22fG AWdJttubPErVRT2vxZ/XQ8A6lSOG1ZbAUdLl40HW4zZLuJ+7j9V/t9j7408yMsQEY7McOIcBvQC hNEzN9TzCpu5874bq48YMgVse4NuDHZdSHKQqru4AOZyiwDLgKNwm+3dXpaxeHSXzdTCC+oO0kU lWNl/KzFSIgMaKRLl4syM5kxRZSNV5Zu7LVYY7q8RPDc2wLOBoZnRtDstilTALv6RgAEiqbtLmD RGgdbfzqVE+gdaXuwclWPRSefGo42mom5a++mRNitkEvLKGNbRNhiW3LmHQ2sPO3u9EN51zXnFR 3ywU0riztx X-Received: by 2002:a05:600c:8b8a:b0:492:2e48:81e6 with SMTP id 5b1f17b1804b1-4925b389b83mr30093645e9.4.1782207762970; Tue, 23 Jun 2026 02:42:42 -0700 (PDT) Received: from localhost ([212.73.77.104]) by smtp.gmail.com with UTF8SMTPSA id 5b1f17b1804b1-49249455302sm280248525e9.15.2026.06.23.02.42.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2026 02:42:42 -0700 (PDT) From: Askar Safin To: avagin@gmail.com Cc: akpm@linux-foundation.org, alexander@mihalicyn.com, axboe@kernel.dk, bernd@bsbernd.com, brauner@kernel.org, criu@lists.linux.dev, david@kernel.org, dhowells@redhat.com, fuse-devel@lists.linux.dev, hch@infradead.org, jack@suse.cz, joannelkoong@gmail.com, linux-api@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, miklos@szeredi.hu, netdev@vger.kernel.org, patches@lists.linux.dev, pfalcato@suse.de, rostedt@goodmis.org, safinaskar@gmail.com, torvalds@linux-foundation.org, val@packett.cool, viro@zeniv.linux.org.uk, willy@infradead.org Subject: Re: [PATCH 0/3] vmsplice: make vmsplice a trivial wrapper for preadv2/pwritev2 Date: Tue, 23 Jun 2026 12:42:11 +0300 Message-ID: <20260623094211.1080873-1-safinaskar@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Andrei Vagin : > Actually, this change introduces a performance and functional > regression for CRIU. > > Here is a brief overview of how CRIU currently dumps memory pages: > > CRIU injects a parasite code blob into the target process's address > space. The parasite invokes vmsplice() with the SPLICE_F_GIFT flag to > pin physical pages directly inside a pipe without copying them. The main > CRIU process then takes over from outside the target context, calling > splice() on the other end of the pipe to stream the data directly into > checkpoint image files or a remote network socket. > > I ran a simple test that creates an anonymous mapping and touches every > page within it: > Without this patch, CRIU takes 9 seconds to dump the test process. > With this patch, It takes 18 seconds... > > Plus, it obviously introduces some memory overhead. > > If these changes are merged, we will need to completely rework the > memory dumping mechanism in CRIU. Using vmsplice() in this proposed form > no longer makes any sense for our architecture... I just have read some docs for CRIU. I found this statement: > #### Why `splice` is Better: > * **Consistency via COW**: The `SPLICE_F_GIFT` flag ensures that if the process modifies a "gifted" page after resuming, the kernel performs a **Copy-on-Write (COW)**. The pipe buffer > continues to hold the *original* version of the page as it existed at the moment of the `vmsplice()` call, ensuring a perfectly consistent snapshot of that page. This is wrong (with released kernels). I confirmed this by testing this on my current kernel (6.12.90). See the code in the end of this message. If you actually rely on mentioned consistency, then, it seems, CRIU is broken. So, in fact, my patch actually brings consistency to CRIU. :) -- Askar Safin #define _GNU_SOURCE #include #include #include #include #include #include #include int main (void) { int p[2]; if (pipe (p) != 0) abort (); char buf[1] = {'a'}; struct iovec iov[] = { { .iov_base = buf, .iov_len = 1, } }; // I pass "SPLICE_F_NONBLOCK | SPLICE_F_GIFT" here, because this is what criu passes if (vmsplice (p[1], iov, 1, SPLICE_F_NONBLOCK | SPLICE_F_GIFT) != 1) abort (); if (close (p[1]) != 0) abort (); buf[0] = 'b'; char buf2[1]; if (read (p[0], buf2, 1) != 1) abort (); printf ("[%c]\n", buf2[0]); // Prints "b" as opposed to "a" on Linux 6.12.90 return 0; }