mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-26 06:45:03 +07:00
fd8aa9095a
Handling of multiple concurrent Xenstore accesses through xenbus driver either from the kernel or user land is rather lame today: xenbus is capable to have one access active only at one point of time. Rewrite xenbus to handle multiple requests concurrently by making use of the request id of the Xenstore protocol. This requires to: - Instead of blocking inside xb_read() when trying to read data from the xenstore ring buffer do so only in the main loop of xenbus_thread(). - Instead of doing writes to the xenstore ring buffer in the context of the caller just queue the request and do the write in the dedicated xenbus thread. - Instead of just forwarding the request id specified by the caller of xenbus to xenstore use a xenbus internal unique request id. This will allow multiple outstanding requests. - Modify the locking scheme in order to allow multiple requests being active in parallel. - Instead of waiting for the reply of a user's xenstore request after writing the request to the xenstore ring buffer return directly to the caller and do the waiting in the read path. Additionally signal handling was optimized by avoiding waking up the xenbus thread or sending an event to Xenstore in case the addressed entity is known to be running already. As a result communication with Xenstore is sped up by a factor of up to 5: depending on the request type (read or write) and the amount of data transferred the gain was at least 20% (small reads) and went up to a factor of 5 for large writes. In the end some more rough edges of xenbus have been smoothed: - Handling of memory shortage when reading from xenstore ring buffer in the xenbus driver was not optimal: it was busy looping and issuing a warning in each loop. - In case of xenstore not running in dom0 but in a stubdom we end up with two xenbus threads running as the initialization of xenbus in dom0 expecting a local xenstored will be redone later when connecting to the xenstore domain. Up to now this was no problem as locking would prevent the two xenbus threads interfering with each other, but this was just a waste of kernel resources. - An out of memory situation while writing to or reading from the xenstore ring buffer no longer will lead to a possible loss of synchronization with xenstore. - The user read and write part are now interruptible by signals. Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
136 lines
4.1 KiB
C
136 lines
4.1 KiB
C
/*
|
|
* Private include for xenbus communications.
|
|
*
|
|
* Copyright (C) 2005 Rusty Russell, IBM Corporation
|
|
* Copyright (C) 2005 XenSource Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
* as published by the Free Software Foundation; or, when distributed
|
|
* separately from the Linux kernel or incorporated into other
|
|
* software packages, subject to the following license:
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this source file (the "Software"), to deal in the Software without
|
|
* restriction, including without limitation the rights to use, copy, modify,
|
|
* merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
|
* and to permit persons to whom the Software is furnished to do so, subject to
|
|
* the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
* IN THE SOFTWARE.
|
|
*/
|
|
|
|
#ifndef _XENBUS_XENBUS_H
|
|
#define _XENBUS_XENBUS_H
|
|
|
|
#include <linux/mutex.h>
|
|
#include <linux/uio.h>
|
|
#include <xen/xenbus.h>
|
|
|
|
#define XEN_BUS_ID_SIZE 20
|
|
|
|
struct xen_bus_type {
|
|
char *root;
|
|
unsigned int levels;
|
|
int (*get_bus_id)(char bus_id[XEN_BUS_ID_SIZE], const char *nodename);
|
|
int (*probe)(struct xen_bus_type *bus, const char *type,
|
|
const char *dir);
|
|
void (*otherend_changed)(struct xenbus_watch *watch, const char *path,
|
|
const char *token);
|
|
struct bus_type bus;
|
|
};
|
|
|
|
enum xenstore_init {
|
|
XS_UNKNOWN,
|
|
XS_PV,
|
|
XS_HVM,
|
|
XS_LOCAL,
|
|
};
|
|
|
|
struct xs_watch_event {
|
|
struct list_head list;
|
|
unsigned int len;
|
|
struct xenbus_watch *handle;
|
|
const char *path;
|
|
const char *token;
|
|
char body[];
|
|
};
|
|
|
|
enum xb_req_state {
|
|
xb_req_state_queued,
|
|
xb_req_state_wait_reply,
|
|
xb_req_state_got_reply,
|
|
xb_req_state_aborted
|
|
};
|
|
|
|
struct xb_req_data {
|
|
struct list_head list;
|
|
wait_queue_head_t wq;
|
|
struct xsd_sockmsg msg;
|
|
enum xsd_sockmsg_type type;
|
|
char *body;
|
|
const struct kvec *vec;
|
|
int num_vecs;
|
|
int err;
|
|
enum xb_req_state state;
|
|
void (*cb)(struct xb_req_data *);
|
|
void *par;
|
|
};
|
|
|
|
extern enum xenstore_init xen_store_domain_type;
|
|
extern const struct attribute_group *xenbus_dev_groups[];
|
|
extern struct mutex xs_response_mutex;
|
|
extern struct list_head xs_reply_list;
|
|
extern struct list_head xb_write_list;
|
|
extern wait_queue_head_t xb_waitq;
|
|
extern struct mutex xb_write_mutex;
|
|
|
|
int xs_init(void);
|
|
int xb_init_comms(void);
|
|
void xb_deinit_comms(void);
|
|
int xs_watch_msg(struct xs_watch_event *event);
|
|
void xs_request_exit(struct xb_req_data *req);
|
|
|
|
int xenbus_match(struct device *_dev, struct device_driver *_drv);
|
|
int xenbus_dev_probe(struct device *_dev);
|
|
int xenbus_dev_remove(struct device *_dev);
|
|
int xenbus_register_driver_common(struct xenbus_driver *drv,
|
|
struct xen_bus_type *bus,
|
|
struct module *owner,
|
|
const char *mod_name);
|
|
int xenbus_probe_node(struct xen_bus_type *bus,
|
|
const char *type,
|
|
const char *nodename);
|
|
int xenbus_probe_devices(struct xen_bus_type *bus);
|
|
|
|
void xenbus_dev_changed(const char *node, struct xen_bus_type *bus);
|
|
|
|
void xenbus_dev_shutdown(struct device *_dev);
|
|
|
|
int xenbus_dev_suspend(struct device *dev);
|
|
int xenbus_dev_resume(struct device *dev);
|
|
int xenbus_dev_cancel(struct device *dev);
|
|
|
|
void xenbus_otherend_changed(struct xenbus_watch *watch,
|
|
const char *path, const char *token,
|
|
int ignore_on_shutdown);
|
|
|
|
int xenbus_read_otherend_details(struct xenbus_device *xendev,
|
|
char *id_node, char *path_node);
|
|
|
|
void xenbus_ring_ops_init(void);
|
|
|
|
int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par);
|
|
void xenbus_dev_queue_reply(struct xb_req_data *req);
|
|
|
|
#endif
|