On Mon, Sep 01, 2025 at 02:22:22PM +0000, Roy, Patrick wrote: > On Thu, 2025-08-28 at 15:54 +0100, Mike Rapoport wrote: > > On Thu, Aug 28, 2025 at 09:39:21AM +0000, Roy, Patrick wrote: > > > >> static inline void kvm_gmem_mark_prepared(struct folio *folio) > >> { > >> + struct inode *inode = folio_inode(folio); > >> + > >> + if (kvm_gmem_test_no_direct_map(inode)) > >> + set_direct_map_valid_noflush(folio_page(folio, 0), folio_nr_pages(folio), false); > > > > This may fail to split large mapping in the direct map. Why not move this > > to kvm_gmem_prepare_folio() where you can handle returned error? > > Argh, yeah, got that the wrong way around. Will update the error handling. > > > I think that using set_direct_map_invalid_noflush() here and > > set_direct_map_default_noflush() in kvm_gmem_free_folio() better is > > clearer and makes it more obvious that here the folio is removed from the > > direct map and when freed it's direct mapping is restored. > > > > This requires to export two symbols in patch 2, but I think it's worth it. > > Mh, but set_direct_map_[default|invalid]_noflush() only take a single struct > page * argument, so they'd either need to gain a npages argument, or we add yet > more functions to set_memory.h. Do you still think that's worth it? Ah, right, misremembered that. Let's keep set_direct_map_valid_noflush(). -- Sincerely yours, Mike.