From: Haren Myneni <haren@linux.ibm.com>
To: Nathan Lynch <nathanl@linux.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: npiggin@gmail.com
Subject: Re: [PATCH] powerpc/pseries/vas: Migration suspend waits for no in-progress open windows
Date: Tue, 10 Oct 2023 22:43:45 -0700 [thread overview]
Message-ID: <ebeaa0f9-5d0e-317f-b0bc-f5212f6c8934@linux.ibm.com> (raw)
In-Reply-To: <8734yjwoax.fsf@li-e15d104c-2135-11b2-a85c-d7ef17e56be6.ibm.com>
On 10/9/23 1:09 PM, Nathan Lynch wrote:
> Hi Haren,
>
> Haren Myneni <haren@linux.ibm.com> writes:
>> The hypervisor returns migration failure if all VAS windows are not
>> closed. During pre-migration stage, vas_migration_handler() sets
>> migration_in_progress flag and closes all windows from the list.
>> The allocate VAS window routine checks the migration flag, setup
>> the window and then add it to the list. So there is possibility of
>> the migration handler missing the window that is still in the
>> process of setup.
>>
>> t1: Allocate and open VAS t2: Migration event
>> window
>>
>> lock vas_pseries_mutex
>> If migration_in_progress set
>> unlock vas_pseries_mutex
>> return
>> open window HCALL
>> unlock vas_pseries_mutex
>> Modify window HCALL lock vas_pseries_mutex
>> setup window migration_in_progress=true
>> Closes all windows from
>> the list
>> unlock vas_pseries_mutex
>> lock vas_pseries_mutex return
>> if nr_closed_windows == 0
>> // No DLPAR CPU or migration
>> add to the list
>> unlock vas_pseries_mutex
>> return
>> unlock vas_pseries_mutex
>> Close VAS window
>> // due to DLPAR CPU or migration
>> return -EBUSY
>
> Could the the path t1 takes simply hold the mutex for the duration of
> its execution instead of dropping and reacquiring it in the middle?
>
> Here's the relevant code from vas_allocate_window():
>
> mutex_lock(&vas_pseries_mutex);
> if (migration_in_progress)
> rc = -EBUSY;
> else
> rc = allocate_setup_window(txwin, (u64 *)&domain[0],
> cop_feat_caps->win_type);
> mutex_unlock(&vas_pseries_mutex);
> if (rc)
> goto out;
>
> rc = h_modify_vas_window(txwin);
> if (!rc)
> rc = get_vas_user_win_ref(&txwin->vas_win.task_ref);
> if (rc)
> goto out_free;
>
> txwin->win_type = cop_feat_caps->win_type;
> mutex_lock(&vas_pseries_mutex);
> if (!caps->nr_close_wins) {
> list_add(&txwin->win_list, &caps->list);
> caps->nr_open_windows++;
> mutex_unlock(&vas_pseries_mutex);
> vas_user_win_add_mm_context(&txwin->vas_win.task_ref);
> return &txwin->vas_win;
> }
> mutex_unlock(&vas_pseries_mutex);
>
> Is there something about h_modify_vas_window() or get_vas_user_win_ref()
> that requires temporarily dropping the lock?
>
Thanks Nathan for your comments.
vas_pseries_mutex protects window ID and IRQ allocation between alloc
and free window HCALLs, and window list. Generally try to not using
mutex in HCALLs, but we need this mutex with these HCALLs.
We can add h_modify_vas_window() or get_vas_user_win_ref() with in the
mutex context, but not needed. Also free HCALL can take longer depends
on pending NX requests since the hypervisor waits for all requests to be
completed before closing the window.
Applications can issue window open / free calls at the same time which
can experience mutex contention especially on the large system where
100's of credits are available. Another example: The migration event can
wait longer (or timeout) to get this mutex if many threads issue
open/free window calls. Hence added h_modify_vas_window() (modify HCALL)
or get_vas_user_win_ref() outside of mutex.
Thanks
Haren
next prev parent reply other threads:[~2023-10-11 5:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 3:15 [PATCH] powerpc/pseries/vas: Migration suspend waits for no in-progress open windows Haren Myneni
2023-10-09 20:09 ` Nathan Lynch
2023-10-11 5:43 ` Haren Myneni [this message]
2023-10-11 20:36 ` Nathan Lynch
2023-10-13 20:22 ` Haren Myneni
2023-10-16 20:30 ` Nathan Lynch
2023-10-16 21:15 ` Haren Myneni
-- strict thread matches above, loose matches on Subject: below --
2023-09-27 3:02 Haren Myneni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ebeaa0f9-5d0e-317f-b0bc-f5212f6c8934@linux.ibm.com \
--to=haren@linux.ibm.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=nathanl@linux.ibm.com \
--cc=npiggin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).