On Wed, Sep 25, 2024 at 8:59 PM Barry Song <baohua@xxxxxxxxxx> wrote: > > On Thu, Sep 26, 2024 at 2:37 AM Nhat Pham <nphamcs@xxxxxxxxx> wrote: > > I’m not entirely clear on your point. If your proposal is to support the > case where usage == 1 and nr > 1 only when we don’t require > CONTINUED, and to issue a warning once we determine that > CONTINUED is needed, then I’m completely on board with that > approach. > > It seems that your intention is to simply relocate the existing warning > to the scenario where CONTINUED is actually required, rather than > maintaining a warning for the case where usage == 1 and nr > 1 at > all times? Ohhh yeah we definitely agreed on intentions, but I think I misunderstood your request :) The code below was an attempt to satisfy that request... Please ignore it. I'll submit an actual patch taking into account our discussions :) Hopefully I won't forget to actually test with thp swaps this time... > > I wasn't actually suggesting a rollback as you posted: > err = __swap_duplicate(entry, 1, nr); > if (err == -ENOMEM) { > /* fallback to non-batched version */ > for (i = 0; i < nr; i++) { > cur_entry = (swp_entry_t){entry.val + i}; > if (swap_duplicate(cur_entry)) { > /* rollback */ > while (--i >= 0) { > cur_entry = (swp_entry_t){entry.val + i}; > swap_free(cur_entry); > } >