On Thu, Mar 23, 2023 at 11:28 AM Chris Li <chrisl@xxxxxxxxxx> wrote: > > On Thu, Mar 23, 2023 at 02:56:24PM +0800, Huang, Ying wrote: > > > > > > Let's assume the swap entry in device A has more than one user. > > > e.g. Swap entry A1 on device A is shared by three different > > > process. It is installed in three PTE locations. > > > > With indirection, the swap ID (swap_desc index) will be installed in > > PTEs instead of the swap entry itself. > > Thanks for the clarification. If we have swap_desc index in the PTE, > let's call it S1. I assume S1 will contain A1 and B1 as part of the > swap_desc struct. > > Now we are getting to some very interesting details. > > What is the life cycle of the S1? Does S1 share the same index as A1? The idea that we are currently discussing does not involve a swap_desc struct. There is only a swap ID that indexes into an xarray that points to a swap_entry. This swap ID and the xarray formulate the indirection layer. I am guessing in this design the swap ID is allocated when unmapping a page to be swapped out, and freed when the underlying swap_entry's swap count falls to 0. Moving a page from a swap backend A to another swap backend B should not be a problem in terms of the swap cache, as we will add it to the swap cache of B, modify the swap ID mapping to point to B, then remove it from the swap cache of A. There are some concerns with this design that I outlined in one of my previous emails, such as having separate swap counting implementation in different swap backends, which is a maintenance burden and error-prone. > > Chris > >