Skip to content

Commit bd6aabc

Browse files
committed
Merge tag 'for-linus-5.10b-rc1c-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip
Pull more xen updates from Juergen Gross: - a series for the Xen pv block drivers adding module parameters for better control of resource usge - a cleanup series for the Xen event driver * tag 'for-linus-5.10b-rc1c-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip: Documentation: add xen.fifo_events kernel parameter description xen/events: unmask a fifo event channel only if it was masked xen/events: only register debug interrupt for 2-level events xen/events: make struct irq_info private to events_base.c xen: remove no longer used functions xen-blkfront: Apply changed parameter name to the document xen-blkfront: add a parameter for disabling of persistent grants xen-blkback: add a parameter for disabling of persistent grants
2 parents 81ecf91 + 1a89c1d commit bd6aabc

File tree

12 files changed

+152
-126
lines changed

12 files changed

+152
-126
lines changed

Documentation/ABI/testing/sysfs-driver-xen-blkback

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,12 @@ Description:
3535
controls the duration in milliseconds that blkback will not
3636
cache any page not backed by a grant mapping.
3737
The default is 10ms.
38+
39+
What: /sys/module/xen_blkback/parameters/feature_persistent
40+
Date: September 2020
41+
KernelVersion: 5.10
42+
Contact: SeongJae Park <[email protected]>
43+
Description:
44+
Whether to enable the persistent grants feature or not. Note
45+
that this option only takes effect on newly created backends.
46+
The default is Y (enable).

Documentation/ABI/testing/sysfs-driver-xen-blkfront

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
What: /sys/module/xen_blkfront/parameters/max
1+
What: /sys/module/xen_blkfront/parameters/max_indirect_segments
22
Date: June 2013
33
KernelVersion: 3.11
44
Contact: Konrad Rzeszutek Wilk <[email protected]>
@@ -8,3 +8,12 @@ Description:
88
is 32 - higher value means more potential throughput but more
99
memory usage. The backend picks the minimum of the frontend
1010
and its default backend value.
11+
12+
What: /sys/module/xen_blkfront/parameters/feature_persistent
13+
Date: September 2020
14+
KernelVersion: 5.10
15+
Contact: SeongJae Park <[email protected]>
16+
Description:
17+
Whether to enable the persistent grants feature or not. Note
18+
that this option only takes effect on newly created frontends.
19+
The default is Y (enable).

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5978,6 +5978,13 @@
59785978
After which time (jiffies) the event handling loop
59795979
should start to delay EOI handling. Default is 2.
59805980

5981+
xen.fifo_events= [XEN]
5982+
Boolean parameter to disable using fifo event handling
5983+
even if available. Normally fifo event handling is
5984+
preferred over the 2-level event handling, as it is
5985+
fairer and the number of possible event channels is
5986+
much higher. Default is on (use fifo events).
5987+
59815988
nopv= [X86,XEN,KVM,HYPER_V,VMWARE]
59825989
Disables the PV optimizations forcing the guest to run
59835990
as generic guest with no PV drivers. Currently support

arch/x86/xen/smp.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,17 @@ int xen_smp_intr_init(unsigned int cpu)
8888
per_cpu(xen_callfunc_irq, cpu).irq = rc;
8989
per_cpu(xen_callfunc_irq, cpu).name = callfunc_name;
9090

91-
debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu);
92-
rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt,
93-
IRQF_PERCPU | IRQF_NOBALANCING,
94-
debug_name, NULL);
95-
if (rc < 0)
96-
goto fail;
97-
per_cpu(xen_debug_irq, cpu).irq = rc;
98-
per_cpu(xen_debug_irq, cpu).name = debug_name;
91+
if (!xen_fifo_events) {
92+
debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu);
93+
rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu,
94+
xen_debug_interrupt,
95+
IRQF_PERCPU | IRQF_NOBALANCING,
96+
debug_name, NULL);
97+
if (rc < 0)
98+
goto fail;
99+
per_cpu(xen_debug_irq, cpu).irq = rc;
100+
per_cpu(xen_debug_irq, cpu).name = debug_name;
101+
}
99102

100103
callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
101104
rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,

arch/x86/xen/xen-ops.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ extern struct start_info *xen_start_info;
2929
extern struct shared_info xen_dummy_shared_info;
3030
extern struct shared_info *HYPERVISOR_shared_info;
3131

32+
extern bool xen_fifo_events;
33+
3234
void xen_setup_mfn_list_list(void);
3335
void xen_build_mfn_list_list(void);
3436
void xen_setup_machphys_mapping(void);

drivers/block/xen-blkback/xenbus.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,12 @@ static void xen_vbd_free(struct xen_vbd *vbd)
473473
vbd->bdev = NULL;
474474
}
475475

476+
/* Enable the persistent grants feature. */
477+
static bool feature_persistent = true;
478+
module_param(feature_persistent, bool, 0644);
479+
MODULE_PARM_DESC(feature_persistent,
480+
"Enables the persistent grants feature");
481+
476482
static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle,
477483
unsigned major, unsigned minor, int readonly,
478484
int cdrom)
@@ -518,6 +524,8 @@ static int xen_vbd_create(struct xen_blkif *blkif, blkif_vdev_t handle,
518524
if (q && blk_queue_secure_erase(q))
519525
vbd->discard_secure = true;
520526

527+
vbd->feature_gnt_persistent = feature_persistent;
528+
521529
pr_debug("Successful creation of handle=%04x (dom=%u)\n",
522530
handle, blkif->domid);
523531
return 0;
@@ -905,7 +913,8 @@ static void connect(struct backend_info *be)
905913

906914
xen_blkbk_barrier(xbt, be, be->blkif->vbd.flush_support);
907915

908-
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u", 1);
916+
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
917+
be->blkif->vbd.feature_gnt_persistent);
909918
if (err) {
910919
xenbus_dev_fatal(dev, err, "writing %s/feature-persistent",
911920
dev->nodename);
@@ -1066,7 +1075,6 @@ static int connect_ring(struct backend_info *be)
10661075
{
10671076
struct xenbus_device *dev = be->dev;
10681077
struct xen_blkif *blkif = be->blkif;
1069-
unsigned int pers_grants;
10701078
char protocol[64] = "";
10711079
int err, i;
10721080
char *xspath;
@@ -1092,9 +1100,11 @@ static int connect_ring(struct backend_info *be)
10921100
xenbus_dev_fatal(dev, err, "unknown fe protocol %s", protocol);
10931101
return -ENOSYS;
10941102
}
1095-
pers_grants = xenbus_read_unsigned(dev->otherend, "feature-persistent",
1096-
0);
1097-
blkif->vbd.feature_gnt_persistent = pers_grants;
1103+
if (blkif->vbd.feature_gnt_persistent)
1104+
blkif->vbd.feature_gnt_persistent =
1105+
xenbus_read_unsigned(dev->otherend,
1106+
"feature-persistent", 0);
1107+
10981108
blkif->vbd.overflow_max_grants = 0;
10991109

11001110
/*
@@ -1117,7 +1127,7 @@ static int connect_ring(struct backend_info *be)
11171127

11181128
pr_info("%s: using %d queues, protocol %d (%s) %s\n", dev->nodename,
11191129
blkif->nr_rings, blkif->blk_protocol, protocol,
1120-
pers_grants ? "persistent grants" : "");
1130+
blkif->vbd.feature_gnt_persistent ? "persistent grants" : "");
11211131

11221132
ring_page_order = xenbus_read_unsigned(dev->otherend,
11231133
"ring-page-order", 0);

drivers/block/xen-blkfront.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,8 +1866,8 @@ static int talk_to_blkback(struct xenbus_device *dev,
18661866
message = "writing protocol";
18671867
goto abort_transaction;
18681868
}
1869-
err = xenbus_printf(xbt, dev->nodename,
1870-
"feature-persistent", "%u", 1);
1869+
err = xenbus_printf(xbt, dev->nodename, "feature-persistent", "%u",
1870+
info->feature_persistent);
18711871
if (err)
18721872
dev_warn(&dev->dev,
18731873
"writing persistent grants feature to xenbus");
@@ -1941,6 +1941,13 @@ static int negotiate_mq(struct blkfront_info *info)
19411941
}
19421942
return 0;
19431943
}
1944+
1945+
/* Enable the persistent grants feature. */
1946+
static bool feature_persistent = true;
1947+
module_param(feature_persistent, bool, 0644);
1948+
MODULE_PARM_DESC(feature_persistent,
1949+
"Enables the persistent grants feature");
1950+
19441951
/**
19451952
* Entry point to this code when a new device is created. Allocate the basic
19461953
* structures and the ring buffer for communication with the backend, and
@@ -2007,6 +2014,8 @@ static int blkfront_probe(struct xenbus_device *dev,
20072014
info->vdevice = vdevice;
20082015
info->connected = BLKIF_STATE_DISCONNECTED;
20092016

2017+
info->feature_persistent = feature_persistent;
2018+
20102019
/* Front end dir is a number, which is used as the id. */
20112020
info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0);
20122021
dev_set_drvdata(&dev->dev, info);
@@ -2316,9 +2325,10 @@ static void blkfront_gather_backend_features(struct blkfront_info *info)
23162325
if (xenbus_read_unsigned(info->xbdev->otherend, "feature-discard", 0))
23172326
blkfront_setup_discard(info);
23182327

2319-
info->feature_persistent =
2320-
!!xenbus_read_unsigned(info->xbdev->otherend,
2321-
"feature-persistent", 0);
2328+
if (info->feature_persistent)
2329+
info->feature_persistent =
2330+
!!xenbus_read_unsigned(info->xbdev->otherend,
2331+
"feature-persistent", 0);
23222332

23232333
indirect_segments = xenbus_read_unsigned(info->xbdev->otherend,
23242334
"feature-max-indirect-segments", 0);

drivers/xen/events/events_2l.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,11 @@ static unsigned evtchn_2l_max_channels(void)
4747
return EVTCHN_2L_NR_CHANNELS;
4848
}
4949

50-
static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu)
50+
static void evtchn_2l_bind_to_cpu(evtchn_port_t evtchn, unsigned int cpu,
51+
unsigned int old_cpu)
5152
{
52-
clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu)));
53-
set_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
53+
clear_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, old_cpu)));
54+
set_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, cpu)));
5455
}
5556

5657
static void evtchn_2l_clear_pending(evtchn_port_t port)

drivers/xen/events/events_base.c

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,57 @@
7070
#undef MODULE_PARAM_PREFIX
7171
#define MODULE_PARAM_PREFIX "xen."
7272

73+
/* Interrupt types. */
74+
enum xen_irq_type {
75+
IRQT_UNBOUND = 0,
76+
IRQT_PIRQ,
77+
IRQT_VIRQ,
78+
IRQT_IPI,
79+
IRQT_EVTCHN
80+
};
81+
82+
/*
83+
* Packed IRQ information:
84+
* type - enum xen_irq_type
85+
* event channel - irq->event channel mapping
86+
* cpu - cpu this event channel is bound to
87+
* index - type-specific information:
88+
* PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM
89+
* guest, or GSI (real passthrough IRQ) of the device.
90+
* VIRQ - virq number
91+
* IPI - IPI vector
92+
* EVTCHN -
93+
*/
94+
struct irq_info {
95+
struct list_head list;
96+
struct list_head eoi_list;
97+
short refcnt;
98+
short spurious_cnt;
99+
enum xen_irq_type type; /* type */
100+
unsigned irq;
101+
evtchn_port_t evtchn; /* event channel */
102+
unsigned short cpu; /* cpu bound */
103+
unsigned short eoi_cpu; /* EOI must happen on this cpu-1 */
104+
unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */
105+
u64 eoi_time; /* Time in jiffies when to EOI. */
106+
107+
union {
108+
unsigned short virq;
109+
enum ipi_vector ipi;
110+
struct {
111+
unsigned short pirq;
112+
unsigned short gsi;
113+
unsigned char vector;
114+
unsigned char flags;
115+
uint16_t domid;
116+
} pirq;
117+
} u;
118+
};
119+
120+
#define PIRQ_NEEDS_EOI (1 << 0)
121+
#define PIRQ_SHAREABLE (1 << 1)
122+
#define PIRQ_MSI_GROUP (1 << 2)
123+
73124
static uint __read_mostly event_loop_timeout = 2;
74125
module_param(event_loop_timeout, uint, 0644);
75126

@@ -110,7 +161,7 @@ static DEFINE_PER_CPU(int [NR_VIRQS], virq_to_irq) = {[0 ... NR_VIRQS-1] = -1};
110161
/* IRQ <-> IPI mapping */
111162
static DEFINE_PER_CPU(int [XEN_NR_IPIS], ipi_to_irq) = {[0 ... XEN_NR_IPIS-1] = -1};
112163

113-
int **evtchn_to_irq;
164+
static int **evtchn_to_irq;
114165
#ifdef CONFIG_X86
115166
static unsigned long *pirq_eoi_map;
116167
#endif
@@ -190,7 +241,7 @@ int get_evtchn_to_irq(evtchn_port_t evtchn)
190241
}
191242

192243
/* Get info for IRQ */
193-
struct irq_info *info_for_irq(unsigned irq)
244+
static struct irq_info *info_for_irq(unsigned irq)
194245
{
195246
if (irq < nr_legacy_irqs())
196247
return legacy_info_ptrs[irq];
@@ -228,7 +279,7 @@ static int xen_irq_info_common_setup(struct irq_info *info,
228279

229280
irq_clear_status_flags(irq, IRQ_NOREQUEST|IRQ_NOAUTOEN);
230281

231-
return xen_evtchn_port_setup(info);
282+
return xen_evtchn_port_setup(evtchn);
232283
}
233284

234285
static int xen_irq_info_evtchn_setup(unsigned irq,
@@ -351,7 +402,7 @@ static enum xen_irq_type type_from_irq(unsigned irq)
351402
return info_for_irq(irq)->type;
352403
}
353404

354-
unsigned cpu_from_irq(unsigned irq)
405+
static unsigned cpu_from_irq(unsigned irq)
355406
{
356407
return info_for_irq(irq)->cpu;
357408
}
@@ -391,7 +442,7 @@ static void bind_evtchn_to_cpu(evtchn_port_t evtchn, unsigned int cpu)
391442
#ifdef CONFIG_SMP
392443
cpumask_copy(irq_get_affinity_mask(irq), cpumask_of(cpu));
393444
#endif
394-
xen_evtchn_port_bind_to_cpu(info, cpu);
445+
xen_evtchn_port_bind_to_cpu(evtchn, cpu, info->cpu);
395446

396447
info->cpu = cpu;
397448
}
@@ -745,7 +796,7 @@ static unsigned int __startup_pirq(unsigned int irq)
745796
info->evtchn = evtchn;
746797
bind_evtchn_to_cpu(evtchn, 0);
747798

748-
rc = xen_evtchn_port_setup(info);
799+
rc = xen_evtchn_port_setup(evtchn);
749800
if (rc)
750801
goto err;
751802

@@ -1145,14 +1196,6 @@ static int bind_interdomain_evtchn_to_irq_chip(unsigned int remote_domain,
11451196
chip);
11461197
}
11471198

1148-
int bind_interdomain_evtchn_to_irq(unsigned int remote_domain,
1149-
evtchn_port_t remote_port)
1150-
{
1151-
return bind_interdomain_evtchn_to_irq_chip(remote_domain, remote_port,
1152-
&xen_dynamic_chip);
1153-
}
1154-
EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irq);
1155-
11561199
int bind_interdomain_evtchn_to_irq_lateeoi(unsigned int remote_domain,
11571200
evtchn_port_t remote_port)
11581201
{
@@ -1320,19 +1363,6 @@ static int bind_interdomain_evtchn_to_irqhandler_chip(
13201363
return irq;
13211364
}
13221365

1323-
int bind_interdomain_evtchn_to_irqhandler(unsigned int remote_domain,
1324-
evtchn_port_t remote_port,
1325-
irq_handler_t handler,
1326-
unsigned long irqflags,
1327-
const char *devname,
1328-
void *dev_id)
1329-
{
1330-
return bind_interdomain_evtchn_to_irqhandler_chip(remote_domain,
1331-
remote_port, handler, irqflags, devname,
1332-
dev_id, &xen_dynamic_chip);
1333-
}
1334-
EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irqhandler);
1335-
13361366
int bind_interdomain_evtchn_to_irqhandler_lateeoi(unsigned int remote_domain,
13371367
evtchn_port_t remote_port,
13381368
irq_handler_t handler,
@@ -2020,8 +2050,8 @@ void xen_setup_callback_vector(void) {}
20202050
static inline void xen_alloc_callback_vector(void) {}
20212051
#endif
20222052

2023-
static bool fifo_events = true;
2024-
module_param(fifo_events, bool, 0);
2053+
bool xen_fifo_events = true;
2054+
module_param_named(fifo_events, xen_fifo_events, bool, 0);
20252055

20262056
static int xen_evtchn_cpu_prepare(unsigned int cpu)
20272057
{
@@ -2050,10 +2080,12 @@ void __init xen_init_IRQ(void)
20502080
int ret = -EINVAL;
20512081
evtchn_port_t evtchn;
20522082

2053-
if (fifo_events)
2083+
if (xen_fifo_events)
20542084
ret = xen_evtchn_fifo_init();
2055-
if (ret < 0)
2085+
if (ret < 0) {
20562086
xen_evtchn_2l_init();
2087+
xen_fifo_events = false;
2088+
}
20572089

20582090
xen_cpu_init_eoi(smp_processor_id());
20592091

0 commit comments

Comments
 (0)