Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 669c743

Browse files
committed
Merge tag 'stable/for-linus-3.10-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen
Pull Xen fixes from Konrad Rzeszutek Wilk: - Regression fix in xen privcmd fixing a memory leak. - Add Documentation for tmem driver. - Simplify and remove code in the tmem driver. - Cleanups. * tag 'stable/for-linus-3.10-rc1-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen: xen: Fixed assignment error in if statement xen/xenbus: Fixed over 80 character limit issue xen/xenbus: Fixed indentation error in switch case xen/tmem: Don't use self[ballooning|shrinking] if frontswap is off. xen/tmem: Remove the usage of '[no|]selfballoon' and use 'tmem.selfballooning' bool instead. xen/tmem: Remove the usage of 'noselfshrink' and use 'tmem.selfshrink' bool instead. xen/tmem: Remove the boot options and fold them in the tmem.X parameters. xen/tmem: s/disable_// and change the logic. xen/tmem: Fix compile warning. xen/tmem: Split out the different module/boot options. xen/tmem: Move all of the boot and module parameters to the top of the file. xen/tmem: Cleanup. Remove the parts that say temporary. xen/privcmd: fix condition in privcmd_close()
2 parents 622f223 + fce9268 commit 669c743

File tree

7 files changed

+82
-106
lines changed

7 files changed

+82
-106
lines changed

Documentation/kernel-parameters.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,6 +3005,27 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
30053005
Force threading of all interrupt handlers except those
30063006
marked explicitly IRQF_NO_THREAD.
30073007

3008+
tmem [KNL,XEN]
3009+
Enable the Transcendent memory driver if built-in.
3010+
3011+
tmem.cleancache=0|1 [KNL, XEN]
3012+
Default is on (1). Disable the usage of the cleancache
3013+
API to send anonymous pages to the hypervisor.
3014+
3015+
tmem.frontswap=0|1 [KNL, XEN]
3016+
Default is on (1). Disable the usage of the frontswap
3017+
API to send swap pages to the hypervisor. If disabled
3018+
the selfballooning and selfshrinking are force disabled.
3019+
3020+
tmem.selfballooning=0|1 [KNL, XEN]
3021+
Default is on (1). Disable the driving of swap pages
3022+
to the hypervisor.
3023+
3024+
tmem.selfshrinking=0|1 [KNL, XEN]
3025+
Default is on (1). Partial swapoff that immediately
3026+
transfers pages from Xen hypervisor back to the
3027+
kernel based on different criteria.
3028+
30083029
topology= [S390]
30093030
Format: {off | on}
30103031
Specify if the kernel should make use of the cpu

drivers/xen/Kconfig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ config XEN_SELFBALLOONING
1919
by the current usage of anonymous memory ("committed AS") and
2020
controlled by various sysfs-settable parameters. Configuring
2121
FRONTSWAP is highly recommended; if it is not configured, self-
22-
ballooning is disabled by default but can be enabled with the
23-
'selfballooning' kernel boot parameter. If FRONTSWAP is configured,
22+
ballooning is disabled by default. If FRONTSWAP is configured,
2423
frontswap-selfshrinking is enabled by default but can be disabled
25-
with the 'noselfshrink' kernel boot parameter; and self-ballooning
26-
is enabled by default but can be disabled with the 'noselfballooning'
24+
with the 'tmem.selfshrink=0' kernel boot parameter; and self-ballooning
25+
is enabled by default but can be disabled with the 'tmem.selfballooning=0'
2726
kernel boot parameter. Note that systems without a sufficiently
2827
large swap device should not enable self-ballooning.
2928

drivers/xen/balloon.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp)
407407
nr_pages = ARRAY_SIZE(frame_list);
408408

409409
for (i = 0; i < nr_pages; i++) {
410-
if ((page = alloc_page(gfp)) == NULL) {
410+
page = alloc_page(gfp);
411+
if (page == NULL) {
411412
nr_pages = i;
412413
state = BP_EAGAIN;
413414
break;

drivers/xen/privcmd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ static void privcmd_close(struct vm_area_struct *vma)
504504
struct page **pages = vma->vm_private_data;
505505
int numpgs = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
506506

507-
if (!xen_feature(XENFEAT_auto_translated_physmap || !numpgs || !pages))
507+
if (!xen_feature(XENFEAT_auto_translated_physmap) || !numpgs || !pages)
508508
return;
509509

510510
xen_unmap_domain_mfn_range(vma, numpgs, pages);

drivers/xen/tmem.c

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111
#include <linux/init.h>
1212
#include <linux/pagemap.h>
1313
#include <linux/cleancache.h>
14-
15-
/* temporary ifdef until include/linux/frontswap.h is upstream */
16-
#ifdef CONFIG_FRONTSWAP
1714
#include <linux/frontswap.h>
18-
#endif
1915

2016
#include <xen/xen.h>
2117
#include <xen/interface/xen.h>
@@ -24,6 +20,34 @@
2420
#include <asm/xen/hypervisor.h>
2521
#include <xen/tmem.h>
2622

23+
#ifndef CONFIG_XEN_TMEM_MODULE
24+
bool __read_mostly tmem_enabled = false;
25+
26+
static int __init enable_tmem(char *s)
27+
{
28+
tmem_enabled = true;
29+
return 1;
30+
}
31+
__setup("tmem", enable_tmem);
32+
#endif
33+
34+
#ifdef CONFIG_CLEANCACHE
35+
static bool cleancache __read_mostly = true;
36+
module_param(cleancache, bool, S_IRUGO);
37+
static bool selfballooning __read_mostly = true;
38+
module_param(selfballooning, bool, S_IRUGO);
39+
#endif /* CONFIG_CLEANCACHE */
40+
41+
#ifdef CONFIG_FRONTSWAP
42+
static bool frontswap __read_mostly = true;
43+
module_param(frontswap, bool, S_IRUGO);
44+
#endif /* CONFIG_FRONTSWAP */
45+
46+
#ifdef CONFIG_XEN_SELFBALLOONING
47+
static bool selfshrinking __read_mostly = true;
48+
module_param(selfshrinking, bool, S_IRUGO);
49+
#endif /* CONFIG_XEN_SELFBALLOONING */
50+
2751
#define TMEM_CONTROL 0
2852
#define TMEM_NEW_POOL 1
2953
#define TMEM_DESTROY_POOL 2
@@ -129,16 +153,6 @@ static int xen_tmem_flush_object(u32 pool_id, struct tmem_oid oid)
129153
return xen_tmem_op(TMEM_FLUSH_OBJECT, pool_id, oid, 0, 0, 0, 0, 0);
130154
}
131155

132-
#ifndef CONFIG_XEN_TMEM_MODULE
133-
bool __read_mostly tmem_enabled = false;
134-
135-
static int __init enable_tmem(char *s)
136-
{
137-
tmem_enabled = true;
138-
return 1;
139-
}
140-
__setup("tmem", enable_tmem);
141-
#endif
142156

143157
#ifdef CONFIG_CLEANCACHE
144158
static int xen_tmem_destroy_pool(u32 pool_id)
@@ -230,20 +244,6 @@ static int tmem_cleancache_init_shared_fs(char *uuid, size_t pagesize)
230244
return xen_tmem_new_pool(shared_uuid, TMEM_POOL_SHARED, pagesize);
231245
}
232246

233-
static bool disable_cleancache __read_mostly;
234-
static bool disable_selfballooning __read_mostly;
235-
#ifdef CONFIG_XEN_TMEM_MODULE
236-
module_param(disable_cleancache, bool, S_IRUGO);
237-
module_param(disable_selfballooning, bool, S_IRUGO);
238-
#else
239-
static int __init no_cleancache(char *s)
240-
{
241-
disable_cleancache = true;
242-
return 1;
243-
}
244-
__setup("nocleancache", no_cleancache);
245-
#endif
246-
247247
static struct cleancache_ops tmem_cleancache_ops = {
248248
.put_page = tmem_cleancache_put_page,
249249
.get_page = tmem_cleancache_get_page,
@@ -361,37 +361,21 @@ static void tmem_frontswap_init(unsigned ignored)
361361
xen_tmem_new_pool(private, TMEM_POOL_PERSIST, PAGE_SIZE);
362362
}
363363

364-
static bool disable_frontswap __read_mostly;
365-
static bool disable_frontswap_selfshrinking __read_mostly;
366-
#ifdef CONFIG_XEN_TMEM_MODULE
367-
module_param(disable_frontswap, bool, S_IRUGO);
368-
module_param(disable_frontswap_selfshrinking, bool, S_IRUGO);
369-
#else
370-
static int __init no_frontswap(char *s)
371-
{
372-
disable_frontswap = true;
373-
return 1;
374-
}
375-
__setup("nofrontswap", no_frontswap);
376-
#endif
377-
378364
static struct frontswap_ops tmem_frontswap_ops = {
379365
.store = tmem_frontswap_store,
380366
.load = tmem_frontswap_load,
381367
.invalidate_page = tmem_frontswap_flush_page,
382368
.invalidate_area = tmem_frontswap_flush_area,
383369
.init = tmem_frontswap_init
384370
};
385-
#else /* CONFIG_FRONTSWAP */
386-
#define disable_frontswap_selfshrinking 1
387371
#endif
388372

389373
static int xen_tmem_init(void)
390374
{
391375
if (!xen_domain())
392376
return 0;
393377
#ifdef CONFIG_FRONTSWAP
394-
if (tmem_enabled && !disable_frontswap) {
378+
if (tmem_enabled && frontswap) {
395379
char *s = "";
396380
struct frontswap_ops *old_ops =
397381
frontswap_register_ops(&tmem_frontswap_ops);
@@ -408,7 +392,7 @@ static int xen_tmem_init(void)
408392
#endif
409393
#ifdef CONFIG_CLEANCACHE
410394
BUG_ON(sizeof(struct cleancache_filekey) != sizeof(struct tmem_oid));
411-
if (tmem_enabled && !disable_cleancache) {
395+
if (tmem_enabled && cleancache) {
412396
char *s = "";
413397
struct cleancache_ops *old_ops =
414398
cleancache_register_ops(&tmem_cleancache_ops);
@@ -419,8 +403,15 @@ static int xen_tmem_init(void)
419403
}
420404
#endif
421405
#ifdef CONFIG_XEN_SELFBALLOONING
422-
xen_selfballoon_init(!disable_selfballooning,
423-
!disable_frontswap_selfshrinking);
406+
/*
407+
* There is no point of driving pages to the swap system if they
408+
* aren't going anywhere in tmem universe.
409+
*/
410+
if (!frontswap) {
411+
selfshrinking = false;
412+
selfballooning = false;
413+
}
414+
xen_selfballoon_init(selfballooning, selfshrinking);
424415
#endif
425416
return 0;
426417
}

drivers/xen/xen-selfballoon.c

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,12 @@
5353
* System configuration note: Selfballooning should not be enabled on
5454
* systems without a sufficiently large swap device configured; for best
5555
* results, it is recommended that total swap be increased by the size
56-
* of the guest memory. Also, while technically not required to be
57-
* configured, it is highly recommended that frontswap also be configured
58-
* and enabled when selfballooning is running. So, selfballooning
59-
* is disabled by default if frontswap is not configured and can only
60-
* be enabled with the "selfballooning" kernel boot option; similarly
61-
* selfballooning is enabled by default if frontswap is configured and
62-
* can be disabled with the "noselfballooning" kernel boot option. Finally,
63-
* when frontswap is configured, frontswap-selfshrinking can be disabled
64-
* with the "noselfshrink" kernel boot option.
56+
* of the guest memory. Note, that selfballooning should be disabled by default
57+
* if frontswap is not configured. Similarly selfballooning should be enabled
58+
* by default if frontswap is configured and can be disabled with the
59+
* "tmem.selfballooning=0" kernel boot option. Finally, when frontswap is
60+
* configured, frontswap-selfshrinking can be disabled with the
61+
* "tmem.selfshrink=0" kernel boot option.
6562
*
6663
* Selfballooning is disallowed in domain0 and force-disabled.
6764
*
@@ -120,9 +117,6 @@ static DECLARE_DELAYED_WORK(selfballoon_worker, selfballoon_process);
120117
/* Enable/disable with sysfs. */
121118
static bool frontswap_selfshrinking __read_mostly;
122119

123-
/* Enable/disable with kernel boot option. */
124-
static bool use_frontswap_selfshrink = true;
125-
126120
/*
127121
* The default values for the following parameters were deemed reasonable
128122
* by experimentation, may be workload-dependent, and can all be
@@ -176,35 +170,6 @@ static void frontswap_selfshrink(void)
176170
frontswap_shrink(tgt_frontswap_pages);
177171
}
178172

179-
static int __init xen_nofrontswap_selfshrink_setup(char *s)
180-
{
181-
use_frontswap_selfshrink = false;
182-
return 1;
183-
}
184-
185-
__setup("noselfshrink", xen_nofrontswap_selfshrink_setup);
186-
187-
/* Disable with kernel boot option. */
188-
static bool use_selfballooning = true;
189-
190-
static int __init xen_noselfballooning_setup(char *s)
191-
{
192-
use_selfballooning = false;
193-
return 1;
194-
}
195-
196-
__setup("noselfballooning", xen_noselfballooning_setup);
197-
#else /* !CONFIG_FRONTSWAP */
198-
/* Enable with kernel boot option. */
199-
static bool use_selfballooning;
200-
201-
static int __init xen_selfballooning_setup(char *s)
202-
{
203-
use_selfballooning = true;
204-
return 1;
205-
}
206-
207-
__setup("selfballooning", xen_selfballooning_setup);
208173
#endif /* CONFIG_FRONTSWAP */
209174

210175
#define MB2PAGES(mb) ((mb) << (20 - PAGE_SHIFT))

drivers/xen/xenbus/xenbus_dev_backend.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,21 @@ static long xenbus_alloc(domid_t domid)
7070
return err;
7171
}
7272

73-
static long xenbus_backend_ioctl(struct file *file, unsigned int cmd, unsigned long data)
73+
static long xenbus_backend_ioctl(struct file *file, unsigned int cmd,
74+
unsigned long data)
7475
{
7576
if (!capable(CAP_SYS_ADMIN))
7677
return -EPERM;
7778

7879
switch (cmd) {
79-
case IOCTL_XENBUS_BACKEND_EVTCHN:
80-
if (xen_store_evtchn > 0)
81-
return xen_store_evtchn;
82-
return -ENODEV;
83-
84-
case IOCTL_XENBUS_BACKEND_SETUP:
85-
return xenbus_alloc(data);
86-
87-
default:
88-
return -ENOTTY;
80+
case IOCTL_XENBUS_BACKEND_EVTCHN:
81+
if (xen_store_evtchn > 0)
82+
return xen_store_evtchn;
83+
return -ENODEV;
84+
case IOCTL_XENBUS_BACKEND_SETUP:
85+
return xenbus_alloc(data);
86+
default:
87+
return -ENOTTY;
8988
}
9089
}
9190

0 commit comments

Comments
 (0)