From nobody Wed Feb 11 02:07:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1673993506; cv=none; d=zohomail.com; s=zohoarc; b=Sy94FN9cKLSIeeVL7idC/GS0U98ycNS633+qTF0wRyr7Rm7ynSOcAY1oWMXvmHzWiHAX2da6KjeATiEpD206x1GfxAp+Q6J8zxr+Uk2w8Zf3/jMcxUOsxnzPPU9OND54udGpURBto/+rA5ItYoUiw5xMmr7PgwoCVAF2lxy+WRc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673993506; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vOgoyenP92MI75OuuSbWf2PpAHEguwfvpUNa2Tx4ejQ=; b=nSwrvu3W9EyCpv68S7hB5hzkrickSIdORWK0JvhNZt8zEZIAdq2F7cC89jb1VeDlNbBDeUHhSXS1uFWvvLmsk+nrYhXB2OAUTIAasqFndGwudL7I12T+H+Jjj9W/Re8QJ8+OReO8qCYeybwA+U5rB9ACfoDdhsiQzUeI9A4syDU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673993506126922.597655931561; Tue, 17 Jan 2023 14:11:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHu9H-0000D2-Pw; Tue, 17 Jan 2023 17:09:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHu9G-00007E-AR for qemu-devel@nongnu.org; Tue, 17 Jan 2023 17:09:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHu9D-0007YX-Lv for qemu-devel@nongnu.org; Tue, 17 Jan 2023 17:09:42 -0500 Received: from mail-vs1-f69.google.com (mail-vs1-f69.google.com [209.85.217.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-507-4Igi9gGjPFqaBlaOpsSeOA-1; Tue, 17 Jan 2023 17:09:36 -0500 Received: by mail-vs1-f69.google.com with SMTP id b65-20020a676744000000b003cedad0ea4bso8210435vsc.9 for ; Tue, 17 Jan 2023 14:09:35 -0800 (PST) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-56-70-30-145-63.dsl.bell.ca. [70.30.145.63]) by smtp.gmail.com with ESMTPSA id bm16-20020a05620a199000b006e16dcf99c8sm21142978qkb.71.2023.01.17.14.09.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 14:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673993377; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vOgoyenP92MI75OuuSbWf2PpAHEguwfvpUNa2Tx4ejQ=; b=Nbo7f1h9b6QL12HPaOJJTibm5p/3jzr1P6/NUoQ+N7zy9aBdxVVvF8zU/tjnilo2cPBioT uCxKCFPEVpXNFfFvMpGoxSG0jj1y5JYtyMTvWxMeJeojX3PmDMluyYAX7A2p4o5tJ/C8dF J4VpR/jtSHoqQ9cmDinlxiE3ZBMbM3A= X-MC-Unique: 4Igi9gGjPFqaBlaOpsSeOA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vOgoyenP92MI75OuuSbWf2PpAHEguwfvpUNa2Tx4ejQ=; b=F4HJRR8x/4C6N0rF0Du9D1DnmHFB5dRQz46TPJyB6tF28Jam358nxnNpBcEPA3pO+J ZeJboyuscV5ZVULpxVx3Hratm/9LsVlYXTlzRL/ltEEOeDRLHzIg2zhP8POQTlMoeG3b aXzFdead/5AQu4O2uS8PpuAy8J1EvPGLlrntf2psBw+vsecY4IMh6C4tj16IPxdYGaQy o+uTie0oZXcXMAjYNeeGZ9ZI+9sym5Y+Lmap+iw2pv0W09/QKGv3oT5ELeyrseto+slg 9ft1UBaQ0v6PkG6+FaadD9YHXfAiZqCGXX3Zpnwem6LZgcPefVCHz4xxlny973FEeXJO 1bdw== X-Gm-Message-State: AFqh2krjtlPuO2q6KYmSED6UnKvWoTzjmhumuzQdvVAG5TU8wEjZR4wR ldkk98mWFiVwlw07c9lUQ2ep3xUm+4MFFcWux3tWtkAjXErEYsQvudF767RCNIy9t3TyQwlHJpY 3F2wtX8K/+rF0ThRsD5SZ3EcX7vj4ubcpuKhJRVqp1mhZKGJLiaG2Rwb28fXjftmz X-Received: by 2002:a05:6102:2f9:b0:3d0:e802:2f7d with SMTP id j25-20020a05610202f900b003d0e8022f7dmr2403844vsj.13.1673993375037; Tue, 17 Jan 2023 14:09:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsGELj8RRaJlcwuKvPt2ZLOgcAn51lq/aLv5xR5o3raou2OBHrIb9nhyhQmIZ8PRiPH3t7oRg== X-Received: by 2002:a05:6102:2f9:b0:3d0:e802:2f7d with SMTP id j25-20020a05610202f900b003d0e8022f7dmr2403814vsj.13.1673993374743; Tue, 17 Jan 2023 14:09:34 -0800 (PST) From: Peter Xu To: qemu-devel@nongnu.org Cc: Leonardo Bras Soares Passos , James Houghton , Juan Quintela , peterx@redhat.com, "Dr . David Alan Gilbert" Subject: [PATCH RFC 07/21] ramblock: Cache file offset for file-backed ramblocks Date: Tue, 17 Jan 2023 17:09:00 -0500 Message-Id: <20230117220914.2062125-8-peterx@redhat.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20230117220914.2062125-1-peterx@redhat.com> References: <20230117220914.2062125-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=peterx@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1673993507485100007 Content-Type: text/plain; charset="utf-8" This value was only used for mmap() when we want to map at a specific offset of the file for memory. To be prepared that we might do another map upon the same range for whatever reason, cache the offset so we know how to map again on the same range. Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- include/exec/ramblock.h | 5 +++++ softmmu/physmem.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/exec/ramblock.h b/include/exec/ramblock.h index adc03df59c..76cd0812c8 100644 --- a/include/exec/ramblock.h +++ b/include/exec/ramblock.h @@ -41,6 +41,11 @@ struct RAMBlock { QLIST_HEAD(, RAMBlockNotifier) ramblock_notifiers; int fd; size_t page_size; + /* + * Cache for file offset to map the ramblock. Only used for + * file-backed ramblocks. + */ + off_t file_offset; /* dirty bitmap used during migration */ unsigned long *bmap; /* bitmap of already received pages in postcopy */ diff --git a/softmmu/physmem.c b/softmmu/physmem.c index a4fb129d8f..aa1a7466e5 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -1543,6 +1543,8 @@ static void *file_ram_alloc(RAMBlock *block, uint32_t qemu_map_flags; void *area; =20 + /* Remember the offset just in case we'll need to map the range again = */ + block->file_offset =3D offset; block->page_size =3D qemu_fd_getpagesize(fd); if (block->mr->align % block->page_size) { error_setg(errp, "alignment 0x%" PRIx64 --=20 2.37.3