Re: [PATCH] memcg: fix hotplugged memory zone oops

2012-11-03 Thread Michal Hocko
On Fri 02-11-12 16:37:37, Hugh Dickins wrote:
> On Fri, 2 Nov 2012, Michal Hocko wrote:
> > On Fri 02-11-12 11:21:59, Michal Hocko wrote:
> > > On Thu 01-11-12 18:28:02, Hugh Dickins wrote:
> > [...]
> > 
> > And I forgot to mention that the following hunk will clash with
> > "memcg: Simplify mem_cgroup_force_empty_list error handling" which is in
> > linux-next already (via Tejun's tree). 
> 
> Oh, via Tejun's tree.  Right, when I checked mmotm there was no problem.

Yeah, whole that thing goes through Tejun's tree because there are many
follow up clean ups depending on that change.

> > Would it be easier to split the patch into the real fix and the hunk
> > bellow? That one doesn't have to go into stable anyway and we would save
> > some merging conflicts. The updated fix on top of -mm tree is bellow for
> > your convinience.
> 
> I'd prefer to leave it as one patch, so even the "future proof" part
> of the fix goes into 3.7 and stable.  But your point is that you have
> already seen the future, and it forks in a slightly different direction!
> 
> Well, I don't want to be obstructive, but it doesn't look difficult
> to resolve.  

True.

> Perhaps if I hold off on splitting them, and see if akpm barks at me
> or not :)
> 
> Hugh
> 
> > > >  /**
> > > > @@ -3688,17 +3712,17 @@ unsigned long mem_cgroup_soft_limit_recl
> > > >  static bool mem_cgroup_force_empty_list(struct mem_cgroup *memcg,
> > > > int node, int zid, enum lru_list lru)
> > > >  {
> > > > -   struct mem_cgroup_per_zone *mz;
> > > > +   struct lruvec *lruvec;
> > > > unsigned long flags, loop;
> > > > struct list_head *list;
> > > > struct page *busy;
> > > > struct zone *zone;
> > > >  
> > > > zone = &NODE_DATA(node)->node_zones[zid];
> > > > -   mz = mem_cgroup_zoneinfo(memcg, node, zid);
> > > > -   list = &mz->lruvec.lists[lru];
> > > > +   lruvec = mem_cgroup_zone_lruvec(zone, memcg);
> > > > +   list = &lruvec->lists[lru];
> > > >  
> > > > -   loop = mz->lru_size[lru];
> > > > +   loop = mem_cgroup_get_lru_size(lruvec, lru);
> > > > /* give some margin against EBUSY etc...*/
> > > > loop += 256;
> > > > busy = NULL;

-- 
Michal Hocko
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [ 044/218] Staging: Android alarm: IOCTL command encoding fix

2012-11-03 Thread Colin Cross
On Fri, Sep 28, 2012 at 1:14 PM, Greg Kroah-Hartman
 wrote:
> 3.4-stable review patch.  If anyone has any objections, please let me know.
>
> --
>
> From: "Dae S. Kim" 
>
> commit 6bd4a5d96c08dc2380f8053b1bd4f879f55cd3c9 upstream.
>
> Fixed a bug. Data was being written to user space using an IOCTL
> command encoded with _IOC_WRITE access mode.
>
> Signed-off-by: Dae S. Kim 
> Signed-off-by: Greg Kroah-Hartman 
>
> ---
>  drivers/staging/android/android_alarm.h |4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> --- a/drivers/staging/android/android_alarm.h
> +++ b/drivers/staging/android/android_alarm.h
> @@ -110,10 +110,12 @@ enum android_alarm_return_flags {
>  #define ANDROID_ALARM_WAIT  _IO('a', 1)
>
>  #define ALARM_IOW(c, type, size)_IOW('a', (c) | ((type) << 4), 
> size)
> +#define ALARM_IOR(c, type, size)_IOR('a', (c) | ((type) << 4), 
> size)
> +
>  /* Set alarm */
>  #define ANDROID_ALARM_SET(type) ALARM_IOW(2, type, struct 
> timespec)
>  #define ANDROID_ALARM_SET_AND_WAIT(type)ALARM_IOW(3, type, struct 
> timespec)
> -#define ANDROID_ALARM_GET_TIME(type)ALARM_IOW(4, type, struct 
> timespec)
> +#define ANDROID_ALARM_GET_TIME(type)ALARM_IOR(4, type, struct 
> timespec)
>  #define ANDROID_ALARM_SET_RTC   _IOW('a', 5, struct timespec)
>  #define ANDROID_ALARM_BASE_CMD(cmd) (cmd & ~(_IOC(0, 0, 0xf0, 0)))
>  #define ANDROID_ALARM_IOCTL_TO_TYPE(cmd)(_IOC_NR(cmd) >> 4)
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

This patch breaks Android userspace by changing the ioctl ABI to
/dev/alarm.  It's definitely not a bug fix, as the IOW vs. IOR flag is
only ever used by drivers, and is not used by alarm-dev.c.

I would have commented sooner, but the original patch was not sent to
any lists I am on, nor any lists that Google can find.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] ACPI 5 support for GPIO, SPI and I2C

2012-11-03 Thread Mika Westerberg
Hi,

With ACPI 5 we can now describe how devices are connected to their bus
using new resources: SPISerialBus and I2CSerialBus. Also it is now possible
to add GPIO connections for the devices with the help of GpioIO and GpioInt
resources.

This series adds support for these new resources.

The series based on the ACPI 5 enumeration support patches that are available
on Rafael's linux-next branch:

git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git 
linux-next

Specifically patches from this thread:

https://lkml.org/lkml/2012/10/31/154

Since these patches depend on the above patches on Rafael's linux-next branch
I suggest that these be merged via that branch, if there are no objections.

The series follows the Device Tree way so that it would be easy to add ACPI
support for the existing SPI and I2C drivers if one is familiar how the
corresponding DT support is done.

For GPIO we introduce a function that maps between ACPI GPIO numbers and Linux
ones - acpi_get_gpio().

SPI slave devices gets enumerated automatically if the master device has
master->dev.acpi_handle set (this is analogous to master->dev.of_mode). The
platform bus code in Rafael's branch assigns the ACPI handle to the master
device.

I2C slave devices can be enumerated by calling acpi_i2c_register_devices() in
the adapter driver.

Thanks,
Mika

Mathias Nyman (1):
  gpio / ACPI: add ACPI support

Mika Westerberg (2):
  spi / ACPI: add ACPI enumeration support
  i2c / ACPI: add ACPI enumeration support

 drivers/acpi/Kconfig|6 ++
 drivers/acpi/Makefile   |1 +
 drivers/acpi/acpi_i2c.c |  234 +++
 drivers/gpio/Kconfig|4 +
 drivers/gpio/Makefile   |1 +
 drivers/gpio/gpiolib-acpi.c |   60 +++
 drivers/i2c/i2c-core.c  |9 ++
 drivers/spi/spi.c   |  231 +-
 include/linux/acpi_gpio.h   |   19 
 include/linux/acpi_i2c.h|   29 ++
 10 files changed, 593 insertions(+), 1 deletion(-)
 create mode 100644 drivers/acpi/acpi_i2c.c
 create mode 100644 drivers/gpio/gpiolib-acpi.c
 create mode 100644 include/linux/acpi_gpio.h
 create mode 100644 include/linux/acpi_i2c.h

-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] i2c / ACPI: add ACPI enumeration support

2012-11-03 Thread Mika Westerberg
ACPI 5 introduced I2cSerialBus resource that makes it possible to enumerate
and configure the I2C slave devices behind the I2C controller. This patch
adds helper functions to support I2C slave enumeration.

An ACPI enabled I2C controller driver only needs to call 
acpi_i2c_register_devices()
in order to get its slave devices enumerated, created and bound to the
corresponding ACPI handle.

Signed-off-by: Mika Westerberg 
Acked-by: Rafael J. Wysocki 
---
 drivers/acpi/Kconfig |6 ++
 drivers/acpi/Makefile|1 +
 drivers/acpi/acpi_i2c.c  |  234 ++
 drivers/i2c/i2c-core.c   |9 ++
 include/linux/acpi_i2c.h |   29 ++
 5 files changed, 279 insertions(+)
 create mode 100644 drivers/acpi/acpi_i2c.c
 create mode 100644 include/linux/acpi_i2c.h

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 119d58d..0300bf6 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -181,6 +181,12 @@ config ACPI_DOCK
  This driver supports ACPI-controlled docking stations and removable
  drive bays such as the IBM Ultrabay and the Dell Module Bay.
 
+config ACPI_I2C
+   def_tristate I2C
+   depends on I2C
+   help
+ ACPI I2C enumeration support.
+
 config ACPI_PROCESSOR
tristate "Processor"
select THERMAL
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index a7badb5..8573346 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -69,6 +69,7 @@ obj-$(CONFIG_ACPI_HED)+= hed.o
 obj-$(CONFIG_ACPI_EC_DEBUGFS)  += ec_sys.o
 obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o
 obj-$(CONFIG_ACPI_BGRT)+= bgrt.o
+obj-$(CONFIG_ACPI_I2C) += acpi_i2c.o
 
 # processor has its own "processor." module_param namespace
 processor-y:= processor_driver.o processor_throttling.o
diff --git a/drivers/acpi/acpi_i2c.c b/drivers/acpi/acpi_i2c.c
new file mode 100644
index 000..dc6997e
--- /dev/null
+++ b/drivers/acpi/acpi_i2c.c
@@ -0,0 +1,234 @@
+/*
+ * ACPI I2C enumeration support
+ *
+ * Copyright (C) 2012, Intel Corporation
+ * Author: Mika Westerberg 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+
+struct acpi_i2c {
+   acpi_status (*callback)(struct acpi_device *, void *);
+   void *data;
+};
+
+static acpi_status acpi_i2c_enumerate_device(acpi_handle handle, u32 level,
+void *data, void **return_value)
+{
+   struct acpi_i2c *acpi_i2c = data;
+   struct acpi_device *adev;
+
+   if (acpi_bus_get_device(handle, &adev))
+   return AE_OK;
+   if (acpi_bus_get_status(adev) || !adev->status.present)
+   return AE_OK;
+
+   return acpi_i2c->callback(adev, acpi_i2c->data);
+}
+
+static acpi_status acpi_i2c_enumerate(acpi_handle handle,
+   acpi_status (*callback)(struct acpi_device *, void *), void *data)
+{
+   struct acpi_i2c acpi_i2c;
+
+   acpi_i2c.callback = callback;
+   acpi_i2c.data = data;
+
+   return acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
+  acpi_i2c_enumerate_device, NULL,
+  &acpi_i2c, NULL);
+}
+
+struct acpi_i2c_device_info {
+   struct i2c_board_info board;
+   int triggering;
+   int polarity;
+   int gsi;
+   bool valid;
+};
+
+static acpi_status acpi_i2c_add_resources(struct acpi_resource *res, void 
*data)
+{
+   struct acpi_i2c_device_info *info = data;
+   struct acpi_resource_i2c_serialbus *sb;
+
+   switch (res->type) {
+   case ACPI_RESOURCE_TYPE_SERIAL_BUS:
+   sb = &res->data.i2c_serial_bus;
+   if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_I2C) {
+   info->board.addr = sb->slave_address;
+   if (sb->access_mode == ACPI_I2C_10BIT_MODE)
+   info->board.flags |= I2C_CLIENT_TEN;
+
+   /*
+* The info is valid once we have found the
+* I2CSerialBus resource.
+*/
+   info->valid = true;
+   }
+   break;
+
+   case ACPI_RESOURCE_TYPE_IRQ:
+   info->gsi = res->data.irq.interrupts[0];
+   info->triggering = res->data.irq.triggering;
+   info->polarity = res->data.irq.polarity;
+   break;
+
+   case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+   info->gsi = res->data.extended_irq.interrupts[0];
+   info->triggering = res->data.extended_irq.triggering;
+   info->polarity = res->data.extended_irq.polarity;
+   break;
+   }
+
+   return AE_OK;
+}
+
+static acpi_status acpi_i2c_add_device(struct acpi_dev

[PATCH 1/3] gpio / ACPI: add ACPI support

2012-11-03 Thread Mika Westerberg
From: Mathias Nyman 

Add support for translating ACPI GPIO pin numbers to Linux GPIO API pins.
Needs a gpio controller driver with the acpi handler hook set.

Drivers can use acpi_get_gpio() to translate ACPI5 GpioIO and GpioInt
resources to Linux GPIO's.

Signed-off-by: Mathias Nyman 
Signed-off-by: Mika Westerberg 
Acked-by: Rafael J. Wysocki 
---
 drivers/gpio/Kconfig|4 +++
 drivers/gpio/Makefile   |1 +
 drivers/gpio/gpiolib-acpi.c |   60 +++
 include/linux/acpi_gpio.h   |   19 ++
 4 files changed, 84 insertions(+)
 create mode 100644 drivers/gpio/gpiolib-acpi.c
 create mode 100644 include/linux/acpi_gpio.h

diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index d055cee..2f1905b 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -49,6 +49,10 @@ config OF_GPIO
def_bool y
depends on OF && !SPARC
 
+config ACPI_GPIO
+   def_bool y
+   depends on ACPI
+
 config DEBUG_GPIO
bool "Debug GPIO calls"
depends on DEBUG_KERNEL
diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 9aeed67..5254b6d 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -4,6 +4,7 @@ ccflags-$(CONFIG_DEBUG_GPIO)+= -DDEBUG
 
 obj-$(CONFIG_GPIOLIB)  += gpiolib.o devres.o
 obj-$(CONFIG_OF_GPIO)  += gpiolib-of.o
+obj-$(CONFIG_ACPI_GPIO)+= gpiolib-acpi.o
 
 # Device drivers. Generally keep list sorted alphabetically
 obj-$(CONFIG_GPIO_GENERIC) += gpio-generic.o
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
new file mode 100644
index 000..ef56ea4
--- /dev/null
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -0,0 +1,60 @@
+/*
+ * ACPI helpers for GPIO API
+ *
+ * Copyright (C) 2012, Intel Corporation
+ * Author: Mathias Nyman 
+ *
+ * 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.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int acpi_gpiochip_find(struct gpio_chip *gc, void *data)
+{
+   acpi_handle handle = data;
+   acpi_handle gc_handle;
+
+   if (!gc->dev)
+   return false;
+
+   gc_handle = gc->dev->acpi_handle;
+   if (!gc_handle)
+   return false;
+
+   return gc_handle == handle;
+}
+
+/**
+ * acpi_get_gpio() - Translate ACPI GPIO pin to GPIO number usable with GPIO 
API
+ * @path:  ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
+ * @pin:   ACPI GPIO pin number (0-based, controller-relative)
+ *
+ * Returns GPIO number to use with Linux generic GPIO API, or errno error value
+ */
+
+int acpi_get_gpio(char *path, int pin)
+{
+   struct gpio_chip *chip;
+   acpi_handle handle;
+   acpi_status status;
+
+   status = acpi_get_handle(NULL, path, &handle);
+   if (ACPI_FAILURE(status))
+   return -ENODEV;
+
+   chip = gpiochip_find(handle, acpi_gpiochip_find);
+   if (!chip)
+   return -ENODEV;
+
+   if (!gpio_is_valid(chip->base + pin))
+   return -EINVAL;
+
+   return chip->base + pin;
+}
+EXPORT_SYMBOL(acpi_get_gpio);
diff --git a/include/linux/acpi_gpio.h b/include/linux/acpi_gpio.h
new file mode 100644
index 000..e025664
--- /dev/null
+++ b/include/linux/acpi_gpio.h
@@ -0,0 +1,19 @@
+#ifndef _LINUX_ACPI_GPIO_H_
+#define _LINUX_ACPI_GPIO_H_
+
+#include 
+
+#ifdef CONFIG_ACPI_GPIO
+
+int acpi_get_gpio(char *path, int pin);
+
+#else /* CONFIG_ACPI_GPIO */
+
+static inline int acpi_get_gpio(char *path, int pin)
+{
+   return -ENODEV;
+}
+
+#endif /* CONFIG_ACPI_GPIO */
+
+#endif /* _LINUX_ACPI_GPIO_H_ */
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/3] spi / ACPI: add ACPI enumeration support

2012-11-03 Thread Mika Westerberg
ACPI 5 introduced SPISerialBus resource that allows us to enumerate and
configure the SPI slave devices behind the SPI controller. This patch adds
support for this to the SPI core.

In addition we bind ACPI nodes to SPI devices. This makes it possible for
the slave drivers to get the ACPI handle for further configuration.

Signed-off-by: Mika Westerberg 
Acked-by: Rafael J. Wysocki 
---
 drivers/spi/spi.c |  231 -
 1 file changed, 230 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
index 84c2861..de22a6e 100644
--- a/drivers/spi/spi.c
+++ b/drivers/spi/spi.c
@@ -35,6 +35,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static void spidev_release(struct device *dev)
 {
@@ -93,6 +94,10 @@ static int spi_match_device(struct device *dev, struct 
device_driver *drv)
if (of_driver_match_device(dev, drv))
return 1;
 
+   /* Then try ACPI */
+   if (acpi_driver_match_device(dev, drv))
+   return 1;
+
if (sdrv->id_table)
return !!spi_match_id(sdrv->id_table, spi);
 
@@ -888,6 +893,227 @@ static void of_register_spi_devices(struct spi_master 
*master)
 static void of_register_spi_devices(struct spi_master *master) { }
 #endif
 
+#ifdef CONFIG_ACPI
+struct acpi_spi {
+   acpi_status (*callback)(struct acpi_device *, void *);
+   void *data;
+};
+
+static acpi_status acpi_spi_enumerate_device(acpi_handle handle, u32 level,
+void *data, void **return_value)
+{
+   struct acpi_spi *acpi_spi = data;
+   struct acpi_device *adev;
+
+   if (acpi_bus_get_device(handle, &adev))
+   return AE_OK;
+   if (acpi_bus_get_status(adev) || !adev->status.present)
+   return AE_OK;
+
+   return acpi_spi->callback(adev, acpi_spi->data);
+}
+
+static acpi_status acpi_spi_enumerate(acpi_handle handle,
+   acpi_status (*callback)(struct acpi_device *, void *), void *data)
+{
+   struct acpi_spi acpi_spi;
+
+   acpi_spi.callback = callback;
+   acpi_spi.data = data;
+
+   return acpi_walk_namespace(ACPI_TYPE_DEVICE, handle, 1,
+  acpi_spi_enumerate_device, NULL,
+  &acpi_spi, NULL);
+}
+
+struct acpi_spi_device_info {
+   struct spi_device *spi;
+   int triggering;
+   int polarity;
+   int gsi;
+   bool valid;
+};
+
+static acpi_status acpi_spi_add_resources(struct acpi_resource *res, void 
*data)
+{
+   struct acpi_spi_device_info *info = data;
+   struct acpi_resource_spi_serialbus *sb;
+   struct spi_device *spi = info->spi;
+
+   switch (res->type) {
+   case ACPI_RESOURCE_TYPE_SERIAL_BUS:
+   sb = &res->data.spi_serial_bus;
+   if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_SPI) {
+   spi->chip_select = sb->device_selection;
+   spi->max_speed_hz = sb->connection_speed;
+
+   /* Mode (clock phase/polarity/etc. */
+   if (sb->clock_phase == ACPI_SPI_SECOND_PHASE)
+   spi->mode |= SPI_CPHA;
+   if (sb->clock_polarity == ACPI_SPI_START_HIGH)
+   spi->mode |= SPI_CPOL;
+   if (sb->device_polarity == ACPI_SPI_ACTIVE_HIGH)
+   spi->mode |= SPI_CS_HIGH;
+
+   /*
+* The info is valid once we have found the
+* SPISerialBus resource.
+*/
+   info->valid = true;
+   }
+   break;
+
+   case ACPI_RESOURCE_TYPE_IRQ:
+   info->gsi = res->data.irq.interrupts[0];
+   info->triggering = res->data.irq.triggering;
+   info->polarity = res->data.irq.polarity;
+   break;
+
+   case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+   info->gsi = res->data.extended_irq.interrupts[0];
+   info->triggering = res->data.extended_irq.triggering;
+   info->polarity = res->data.extended_irq.polarity;
+   break;
+   }
+
+   return AE_OK;
+}
+
+static acpi_status acpi_spi_add_device(struct acpi_device *adev, void *data)
+{
+   struct acpi_spi_device_info info;
+   struct spi_master *master = data;
+   struct spi_device *spi;
+   acpi_status status;
+
+   spi = spi_alloc_device(master);
+   if (!spi) {
+   dev_err(&master->dev, "failed to allocate SPI device\n");
+   return AE_ERROR;
+   }
+
+   memset(&info, 0, sizeof(info));
+   info.spi = spi;
+   info.gsi = -1;
+
+   status = acpi_walk_resources(adev->handle, METHOD_NAME__CRS,
+acpi_spi_add_resources, &info);
+   if (ACPI_FAILURE(status) || !info.valid)
+   goto fail_put_dev;
+
+

Re: [PATCH 0/3] Volatile Ranges (v7) & Lots of words

2012-11-03 Thread Michael Kerrisk
[CC += linux-api, since this is an API change.]

Hi John,

A couple of other questions that occurred to me...

What are the expected/planned semantics of volatile ranges for mlocked
pages? I noticed that Minchan's patch series
(https://lwn.net/Articles/522154/) gives an error on attempt to mark
locked pages as volatile (which seems sensible). I didn't see anything
similar in your patches. Perhaps it's not easy to do because of the
non-VMA-based implementation? Something to think about.

On Wed, Oct 3, 2012 at 12:38 AM, John Stultz  wrote:
> On 10/02/2012 12:39 AM, NeilBrown wrote:
>>
>> On Fri, 28 Sep 2012 23:16:30 -0400 John Stultz 
>> wrote:
>>
>>   For example, allowing sub-page volatile region seems to be above and
>> beyond
>>   the call of duty.  You cannot mmap sub-pages, so why should they be
>> volatile?
>
> Although if someone marked a page and a half as volatile, would it be
> reasonable to throw away the second half of that second page? That seems
> unexpected to me. So we're really only marking the whole pages specified as
> volatlie,  similar to how FALLOC_FL_PUNCH_HOLE behaves.
>
> But if it happens that the adjacent range is also a partial page, we can
> coalesce them possibly into an purgable whole page. I think it makes sense,
> especially from a userland point of view and wasn't really complicated to
> add.

I must confess that I'm puzzled by this facility to lock sub-page
range ranges as well. What's the use case? What I'm thinking is: the
goal of volatile ranges is to help improve system performance by
freeing up a (sizeable) block of pages. Why then would the user care
too much about marking with sub-page granularity, or that such ranges
might be merged? After all, the system calls to do this marking are
expensive, and so for performance reasons, I suppose that a process
would like to keep those system calls to a minimum.

[...]

>>   I think discarding whole ranges at a time is very sensible, and so
>> merging
>>   adjacent ranges is best avoided.  If you require page-aligned ranges
>> this
>>   becomes trivial - is that right?
>
> True. If we avoid coalescing non-whole page ranges, keeping non-overlapping
> ranges independent is fairly easy.

Regarding coalescing of adjacent ranges. Here's one possible argument
against it (Jake Edge alerted me to this). If an application marked
adjacent ranges using separate system calls, that might be an
indication that the application intends to to have different access
patterns against the two ranges: one frequent, the other rare. In that
case, I suppose it would be better if the ranges were not merged.

Cheers,

Michael

-- 
Michael Kerrisk Linux man-pages maintainer;
http://www.kernel.org/doc/man-pages/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Is this a kernel bug?

2012-11-03 Thread Cyberman Wu
Recent days we got a exception in kernel thread [kworker/n:m], but
exception handler
call do_group_exit() -> do_exit() -> schedule() and got another
exception in schedule():
/*
 * If a worker is going to sleep, notify and
 * ask workqueue whether it wants to wake up a
 * task to maintain concurrency.  If so, wake
 * up the task.
 */
if (prev->flags & PF_WQ_WORKER) {
struct task_struct *to_wakeup;

to_wakeup = wq_worker_sleeping(prev, cpu);
if (to_wakeup)
try_to_wake_up_local(to_wakeup);
}

Exception occurred while wq_worker_sleeping() -> kthread_data().

It's because do_exit() -> exit_mm() -> mm_release():
/* notify parent sleeping on vfork() */
if (vfork_done) {
tsk->vfork_done = NULL;
complete(vfork_done);
}

I'm using a patched version of kernel 2.6.38.8. But I've checked code
of kernel version 3.6.5,
it seems have the same process, only with files and functions split.



-- 
Cyberman Wu
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 1/9] net: core: use this_cpu_ptr per-cpu helper

2012-11-03 Thread Steffen Klassert
On Fri, Nov 02, 2012 at 05:44:55PM +, Christoph Lameter wrote:
> On Sat, 3 Nov 2012, Shan Wei wrote:
> > +++ b/net/core/flow.c
> > @@ -327,11 +327,9 @@ static void flow_cache_flush_tasklet(unsigned long 
> > data)
> >  static void flow_cache_flush_per_cpu(void *data)
> >  {
> > struct flow_flush_info *info = data;
> > -   int cpu;
> > struct tasklet_struct *tasklet;
> >
> > -   cpu = smp_processor_id();
> > -   tasklet = &per_cpu_ptr(info->cache->percpu, cpu)->flush_tasklet;
> > +   tasklet = &this_cpu_ptr(info->cache->percpu)->flush_tasklet
> 
> Another case for the use of this_cpu_read

Actually, smp_processor_id() is used if either preemtion is off or
in a thread that is bound to the current cpu. So all code that uses
smp_processor_id() should be able to use __this_cpu_read instead of
this_cpu_read.

In this case, flow_cache_flush_per_cpu() is called via smp_call_function(),
so it is bound on the current cpu.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 5/9] kernel: padata : use this_cpu_read per-cpu helper

2012-11-03 Thread Steffen Klassert
>  
> @@ -204,8 +204,7 @@ static struct padata_priv *padata_get_next(struct 
> parallel_data *pd)
>   goto out;
>   }
>  
> - queue = per_cpu_ptr(pd->pqueue, smp_processor_id());
> - if (queue->cpu_index == next_queue->cpu_index) {
> + if (this_cpu_read(pd->pqueue->cpu_index) == next_queue->cpu_index) {

This runs with bottom halves off, so we can use __this_cpu_read here.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: BUG: enabling psacct breaks fsfreeze

2012-11-03 Thread Marco Stornelli

Il 02/11/2012 11:40, Nikola Ciprich ha scritto:

I saw this behavior (task-hang) when I tested the fsfreeze code. I was
writing a little patch to replace fsfreeze's wait queue with a killable
queue, in this way the user can do at least "kill -9", but since the
behavior was the same before your patch I didn't send it. I don't know if we
can break any previous behavior. The funny thing here is that it's like if
fsfreeze freezes itself :)


I think freezing all tasks ain't that bad, my problem is it's not possible to
start fsfreeze -u to thaw filesystem..




Yes, of course. It was only a general comment.

Marco
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 0/6] solve deadlock caused by memory allocation with I/O

2012-11-03 Thread Ming Lei
This patchset try to solve one deadlock problem which might be caused
by memory allocation with block I/O during runtime PM and block device
error handling path. Traditionly, the problem is addressed by passing
GFP_NOIO statically to mm, but that is not a effective solution, see
detailed description in patch 1's commit log.

This patch set introduces one process flag and trys to fix the deadlock
problem on block device/network device during runtime PM or usb bus reset.

The 1st one is the change on include/sched.h and mm.

The 2nd patch introduces the flag of memalloc_noio on 'dev_pm_info',
and pm_runtime_set_memalloc_noio(), so that PM Core can teach mm to not
allocate mm with GFP_IOFS during the runtime_resume callback only on
device with the flag set.

The following 2 patches apply the introduced pm_runtime_set_memalloc_noio()
to mark all devices as memalloc_noio_resume in the path from the block or
network device to the root device in device tree.

The last 2 patches are applied again PM and USB subsystem to demonstrate
how to use the introduced mechanism to fix the deadlock problem.

Change logs:
V4:
- patches from the 2nd to the 6th changed   
- call pm_runtime_set_memalloc_noio() after device_add() as pointed
by Alan
- set PF_MEMALLOC_NOIO during runtime_suspend()

V3:
- patch 2/6 and 5/6 changed, see their commit log
- remove RFC from title since several guys have expressed that
it is a reasonable solution
V2:
- remove changes on 'may_writepage' and 'may_swap'(1/6)
- unset GFP_IOFS in try_to_free_pages() path(1/6)
- introduce pm_runtime_set_memalloc_noio()
- only apply the meachnism on block/network device and its ancestors
for runtime resume context
V1:
- take Minchan's change to avoid the check in alloc_page hot path
- change the helpers' style into save/restore as suggested by Alan
- memory allocation with no io in usb bus reset path for all devices
as suggested by Greg and Oliver

 block/genhd.c|9 +
 drivers/base/power/runtime.c |   89 +-
 drivers/usb/core/hub.c   |   13 ++
 include/linux/pm.h   |1 +
 include/linux/pm_runtime.h   |3 ++
 include/linux/sched.h|   10 +
 mm/page_alloc.c  |   10 -
 mm/vmscan.c  |   12 ++
 net/core/net-sysfs.c |5 +++


Thanks,
--
Ming Lei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 1/6] mm: teach mm by current context info to not do I/O during memory allocation

2012-11-03 Thread Ming Lei
This patch introduces PF_MEMALLOC_NOIO on process flag('flags' field of
'struct task_struct'), so that the flag can be set by one task
to avoid doing I/O inside memory allocation in the task's context.

The patch trys to solve one deadlock problem caused by block device,
and the problem may happen at least in the below situations:

- during block device runtime resume, if memory allocation with
GFP_KERNEL is called inside runtime resume callback of any one
of its ancestors(or the block device itself), the deadlock may be
triggered inside the memory allocation since it might not complete
until the block device becomes active and the involed page I/O finishes.
The situation is pointed out first by Alan Stern. It is not a good
approach to convert all GFP_KERNEL[1] in the path into GFP_NOIO because
several subsystems may be involved(for example, PCI, USB and SCSI may
be involved for usb mass stoarage device, network devices involved too
in the iSCSI case)

- during block device runtime suspend, because runtime resume need
to wait for completion of concurrent runtime suspend.

- during error handling of usb mass storage deivce, USB bus reset
will be put on the device, so there shouldn't have any
memory allocation with GFP_KERNEL during USB bus reset, otherwise
the deadlock similar with above may be triggered. Unfortunately, any
usb device may include one mass storage interface in theory, so it
requires all usb interface drivers to handle the situation. In fact,
most usb drivers don't know how to handle bus reset on the device
and don't provide .pre_set() and .post_reset() callback at all, so
USB core has to unbind and bind driver for these devices. So it
is still not practical to resort to GFP_NOIO for solving the problem.

Also the introduced solution can be used by block subsystem or block
drivers too, for example, set the PF_MEMALLOC_NOIO flag before doing
actual I/O transfer.

It is not a good idea to convert all these GFP_KERNEL in the
affected path into GFP_NOIO because these functions doing that may be
implemented as library and will be called in many other contexts.

In fact, memalloc_noio() can convert some of current static GFP_NOIO
allocation into GFP_KERNEL back in other non-affected contexts, at least
almost all GFP_NOIO in USB subsystem can be converted into GFP_KERNEL
after applying the approach and make allocation with GFP_IO
only happen in runtime resume/bus reset/block I/O transfer contexts
generally.

[1], several GFP_KERNEL allocation examples in runtime resume path

- pci subsystem
acpi_os_allocate
<-acpi_ut_allocate
<-ACPI_ALLOCATE_ZEROED
<-acpi_evaluate_object
<-__acpi_bus_set_power
<-acpi_bus_set_power
<-acpi_pci_set_power_state

<-platform_pci_set_power_state

<-pci_platform_power_transition

<-__pci_complete_power_transition

<-pci_set_power_state

<-pci_restore_standard_config

<-pci_pm_runtime_resume
- usb subsystem
usb_get_status
<-finish_port_resume
<-usb_port_resume
<-generic_resume
<-usb_resume_device
<-usb_resume_both
<-usb_runtime_resume

- some individual usb drivers
usblp, uvc, gspca, most of dvb-usb-v2 media drivers, cpia2, az6007, 

That is just what I have found.  Unfortunately, this allocation can
only be found by human being now, and there should be many not found
since any function in the resume path(call tree) may allocate memory
with GFP_KERNEL.

Cc: Alan Stern 
Cc: Oliver Neukum 
Cc: Jiri Kosina 
Cc: Andrew Morton 
Cc: Mel Gorman 
Cc: KAMEZAWA Hiroyuki 
Cc: Michal Hocko 
Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Cc: "Rafael J. Wysocki" 
Signed-off-by: Minchan Kim 
Signed-off-by: Ming Lei 
---
v4:
- fix comment
v3:
- no change
v2:
- remove changes on 'may_writepage' and 'may_swap' because that
  isn't related with the patchset, and can't introduce I/O in
  allocation path if GFP_IOFS is unset, so handing 'may_swap'
  and may_writepage on GFP_NOIO or GFP_NOFS  should be a
  mm internal thing, and let mm guys deal with that, :-).

  Looks clearing the two may_XXX flag only excludes dirty pages
  and anon pages for relaiming, and the behaviour should be 
decided
  by GFP FLAG, IMO.

- unset GFP_IOFS i

[PATCH v4 2/6] PM / Runtime: introduce pm_runtime_set_memalloc_noio()

2012-11-03 Thread Ming Lei
The patch introduces the flag of memalloc_noio in 'struct dev_pm_info'
to help PM core to teach mm not allocating memory with GFP_KERNEL
flag for avoiding probable deadlock.

As explained in the comment, any GFP_KERNEL allocation inside
runtime_resume() or runtime_suspend() on any one of device in
the path from one block or network device to the root device
in the device tree may cause deadlock, the introduced
pm_runtime_set_memalloc_noio() sets or clears the flag on
device in the path recursively.

Cc: Alan Stern 
Cc: "Rafael J. Wysocki" 
Signed-off-by: Ming Lei 
---
v4:
- rename memalloc_noio_resume as memalloc_noio
- remove pm_runtime_get_memalloc_noio()
- add comments on pm_runtime_set_memalloc_noio
v3:
- introduce pm_runtime_get_memalloc_noio()
- hold one global lock on pm_runtime_set_memalloc_noio
- hold device power lock when accessing memalloc_noio_resume
  flag suggested by Alan Stern
- implement pm_runtime_set_memalloc_noio without recursion
  suggested by Alan Stern
v2:
- introduce pm_runtime_set_memalloc_noio()
---
 drivers/base/power/runtime.c |   57 ++
 include/linux/pm.h   |1 +
 include/linux/pm_runtime.h   |3 +++
 3 files changed, 61 insertions(+)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 3148b10..d477924 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -124,6 +124,63 @@ unsigned long pm_runtime_autosuspend_expiration(struct 
device *dev)
 }
 EXPORT_SYMBOL_GPL(pm_runtime_autosuspend_expiration);
 
+static int dev_memalloc_noio(struct device *dev, void *data)
+{
+   return dev->power.memalloc_noio;
+}
+
+/*
+ * pm_runtime_set_memalloc_noio - Set a device's memalloc_noio flag.
+ * @dev: Device to handle.
+ * @enable: True for setting the flag and False for clearing the flag.
+ *
+ * Set the flag for all devices in the path from the device to the
+ * root device in the device tree if @enable is true, otherwise clear
+ * the flag for devices in the path whose siblings don't set the flag.
+ *
+ * The function should only be called by block device, or network
+ * device driver for solving the deadlock problem during runtime
+ * resume/suspend:
+ * if memory allocation with GFP_KERNEL is called inside runtime
+ * resume/suspend callback of any one of its ancestors(or the
+ * block device itself), the deadlock may be triggered inside the
+ * memory allocation since it might not complete until the block
+ * device becomes active and the involed page I/O finishes. The
+ * situation is pointed out first by Alan Stern. Network device
+ * are involved in iSCSI kind of situation.
+ *
+ * The lock of dev_hotplug_mutex is held in the function for handling
+ * hotplug race because pm_runtime_set_memalloc_noio() may be called
+ * in async probe().
+ *
+ * The function should be called between device_add() and device_del()
+ * on the affected device(block/network device).
+ */
+void pm_runtime_set_memalloc_noio(struct device *dev, bool enable)
+{
+   static DEFINE_MUTEX(dev_hotplug_mutex);
+
+   mutex_lock(&dev_hotplug_mutex);
+   for(;;) {
+   /* hold power lock since bitfield is not SMP-safe. */
+   spin_lock_irq(&dev->power.lock);
+   dev->power.memalloc_noio = enable;
+   spin_unlock_irq(&dev->power.lock);
+
+   dev = dev->parent;
+
+   /* only clear the flag for one device if all
+* children of the device don't set the flag.
+*/
+   if (!dev || (!enable &&
+device_for_each_child(dev, NULL,
+  dev_memalloc_noio)))
+   break;
+   }
+   mutex_unlock(&dev_hotplug_mutex);
+}
+EXPORT_SYMBOL_GPL(pm_runtime_set_memalloc_noio);
+
 /**
  * rpm_check_suspend_allowed - Test whether a device may be suspended.
  * @dev: Device to test.
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 03d7bb1..1a8a69d 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -538,6 +538,7 @@ struct dev_pm_info {
unsigned intirq_safe:1;
unsigned intuse_autosuspend:1;
unsigned inttimer_autosuspends:1;
+   unsigned intmemalloc_noio:1;
enum rpm_requestrequest;
enum rpm_status runtime_status;
int runtime_error;
diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
index f271860..775e063 100644
--- a/include/linux/pm_runtime.h
+++ b/include/linux/pm_runtime.h
@@ -47,6 +47,7 @@ extern void pm_runtime_set_autosuspend_delay(struct device 
*dev, int delay);
 extern unsigned long pm_runtime_autosuspend_expiration(struct device *dev);
 extern void pm_runtime_update_max_time_suspended(struct device *dev,

[PATCH v4 3/6] block/genhd.c: apply pm_runtime_set_memalloc_noio on block devices

2012-11-03 Thread Ming Lei
This patch applyes the introduced pm_runtime_set_memalloc_noio on
block device so that PM core will teach mm to not allocate memory with
GFP_IOFS when calling the runtime_resume and runtime_suspend callback
for block devices and its ancestors.

Cc: Jens Axboe 
Signed-off-by: Ming Lei 
---
v4:
- call pm_runtime_set_memalloc_noio(ddev, true) after device_add
---
 block/genhd.c |9 +
 1 file changed, 9 insertions(+)

diff --git a/block/genhd.c b/block/genhd.c
index 9e02cd6..f3fe3aa 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -18,6 +18,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "blk.h"
 
@@ -532,6 +533,13 @@ static void register_disk(struct gendisk *disk)
return;
}
}
+
+   /* avoid probable deadlock caused by allocating memory with
+* GFP_KERNEL in runtime_resume callback of its all ancestor
+* deivces
+*/
+   pm_runtime_set_memalloc_noio(ddev, true);
+
disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj);
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
 
@@ -661,6 +669,7 @@ void del_gendisk(struct gendisk *disk)
disk->driverfs_dev = NULL;
if (!sysfs_deprecated)
sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
+   pm_runtime_set_memalloc_noio(disk_to_dev(disk), false);
device_del(disk_to_dev(disk));
 }
 EXPORT_SYMBOL(del_gendisk);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 4/6] net/core: apply pm_runtime_set_memalloc_noio on network devices

2012-11-03 Thread Ming Lei
Deadlock might be caused by allocating memory with GFP_KERNEL in
runtime_resume and runtime_suspend callback of network devices in
iSCSI situation, so mark network devices and its ancestor as
'memalloc_noio' with the introduced pm_runtime_set_memalloc_noio().

Cc: "David S. Miller" 
Cc: Eric Dumazet 
Cc: David Decotigny 
Cc: Tom Herbert 
Cc: Ingo Molnar 
Signed-off-by: Ming Lei 
---
v4:
 - call pm_runtime_set_memalloc_noio(ddev, true) after
   device_add
---
 net/core/net-sysfs.c |5 +
 1 file changed, 5 insertions(+)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index bcf02f6..a55d255 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include "net-sysfs.h"
@@ -1386,6 +1387,8 @@ void netdev_unregister_kobject(struct net_device * net)
 
remove_queue_kobjects(net);
 
+   pm_runtime_set_memalloc_noio(dev, false);
+
device_del(dev);
 }
 
@@ -1421,6 +1424,8 @@ int netdev_register_kobject(struct net_device *net)
return error;
}
 
+   pm_runtime_set_memalloc_noio(dev, true);
+
return error;
 }
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 5/6] PM / Runtime: force memory allocation with no I/O during Runtime PM callbcack

2012-11-03 Thread Ming Lei
This patch applies the introduced memalloc_noio_save() and
memalloc_noio_restore() to force memory allocation with no I/O
during runtime_resume/runtime_suspend callback on device with
the flag of 'memalloc_noio' set.

Cc: Alan Stern 
Cc: Oliver Neukum 
Cc: Rafael J. Wysocki 
Signed-off-by: Ming Lei 
---
v4:
- runtime_suspend need this too because rpm_resume may wait for
completion of concurrent runtime_suspend, so deadlock still may
be triggered in runtime_suspend path.
---
 drivers/base/power/runtime.c |   32 ++--
 1 file changed, 30 insertions(+), 2 deletions(-)

diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index d477924..7ed17a9 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -368,6 +368,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
int (*callback)(struct device *);
struct device *parent = NULL;
int retval;
+   unsigned int noio_flag;
 
trace_rpm_suspend(dev, rpmflags);
 
@@ -477,7 +478,20 @@ static int rpm_suspend(struct device *dev, int rpmflags)
if (!callback && dev->driver && dev->driver->pm)
callback = dev->driver->pm->runtime_suspend;
 
-   retval = rpm_callback(callback, dev);
+   /*
+* Deadlock might be caused if memory allocation with GFP_KERNEL
+* happens inside runtime_suspend callback of one block device's
+* ancestor or the block device itself. Network device might be
+* thought as part of iSCSI block device, so network device and
+* its ancestor should be marked as memalloc_noio.
+*/
+   if (dev->power.memalloc_noio) {
+   memalloc_noio_save(noio_flag);
+   retval = rpm_callback(callback, dev);
+   memalloc_noio_restore(noio_flag);
+   } else {
+   retval = rpm_callback(callback, dev);
+   }
if (retval)
goto fail;
 
@@ -560,6 +574,7 @@ static int rpm_resume(struct device *dev, int rpmflags)
int (*callback)(struct device *);
struct device *parent = NULL;
int retval = 0;
+   unsigned int noio_flag;
 
trace_rpm_resume(dev, rpmflags);
 
@@ -709,7 +724,20 @@ static int rpm_resume(struct device *dev, int rpmflags)
if (!callback && dev->driver && dev->driver->pm)
callback = dev->driver->pm->runtime_resume;
 
-   retval = rpm_callback(callback, dev);
+   /*
+* Deadlock might be caused if memory allocation with GFP_KERNEL
+* happens inside runtime_resume callback of one block device's
+* ancestor or the block device itself. Network device might be
+* thought as part of iSCSI block device, so network device and
+* its ancestor should be marked as memalloc_noio.
+*/
+   if (dev->power.memalloc_noio) {
+   memalloc_noio_save(noio_flag);
+   retval = rpm_callback(callback, dev);
+   memalloc_noio_restore(noio_flag);
+   } else {
+   retval = rpm_callback(callback, dev);
+   }
if (retval) {
__update_runtime_status(dev, RPM_SUSPENDED);
pm_runtime_cancel_pending(dev);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH v4 6/6] USB: forbid memory allocation with I/O during bus reset

2012-11-03 Thread Ming Lei
If one storage interface or usb network interface(iSCSI case)
exists in current configuration, memory allocation with
GFP_KERNEL during usb_device_reset() might trigger I/O transfer
on the storage interface itself and cause deadlock because
the 'us->dev_mutex' is held in .pre_reset() and the storage
interface can't do I/O transfer when the reset is triggered
by other interface, or the error handling can't be completed
if the reset is triggered by the storage itself(error handling path).

Cc: Alan Stern 
Cc: Oliver Neukum 
Signed-off-by: Ming Lei 
---
v4:
- mark current memalloc_noio for every usb device reset
---
 drivers/usb/core/hub.c |   13 +
 1 file changed, 13 insertions(+)

diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 5b131b6..788e652 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -5044,6 +5044,7 @@ int usb_reset_device(struct usb_device *udev)
 {
int ret;
int i;
+   unsigned int noio_flag;
struct usb_host_config *config = udev->actconfig;
 
if (udev->state == USB_STATE_NOTATTACHED ||
@@ -5053,6 +5054,17 @@ int usb_reset_device(struct usb_device *udev)
return -EINVAL;
}
 
+   /*
+* Don't allocate memory with GFP_KERNEL in current
+* context to avoid possible deadlock if usb mass
+* storage interface or usbnet interface(iSCSI case)
+* is included in current configuration. The easist
+* approach is to do it for every device reset,
+* because the device 'memalloc_noio' flag may have
+* not been set before reseting the usb device.
+*/
+   memalloc_noio_save(noio_flag);
+
/* Prevent autosuspend during the reset */
usb_autoresume_device(udev);
 
@@ -5097,6 +5109,7 @@ int usb_reset_device(struct usb_device *udev)
}
 
usb_autosuspend_device(udev);
+   memalloc_noio_restore(noio_flag);
return ret;
 }
 EXPORT_SYMBOL_GPL(usb_reset_device);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCHSET cgroup/for-3.8] cgroup_freezer: implement proper hierarchy support

2012-11-03 Thread Tejun Heo
Hello,

This patchset implement proper hierarchy support for cgroup_freezer as
discussed in "[RFC] cgroup TODOs"[1].

The patchset first implements generic cgroup iteration macros -
cgroup_for_each_children(), cgroup_for_each_descendant_{pre|post}().
Combined with the newly introduced ->post_create() callback, this
allows controllers to implement reliable iteration over descendants
without messing with cgroup internal locking.  Controllers can perform
reliable walking using simple hierarchy-wide locking or finer-grained
parent-children locking.

Using the iteration macros and ->post_create(), cgroup_freezer is
updated to propagate state updates to and collect FROZEN completions
from the descendants.  This removes .broken_hierarchy marking from
cgroup_freezer.

cgroup_freezer hierarchy support is implemented using finer-grained
locking not necessarily because it's necessary but more because I
wanted an example controller doing that.

This patchset contains the following nine patches.

 0001-cgroup-add-cgroup_subsys-post_create.patch
 0002-cgroup-Use-rculist-ops-for-cgroup-children.patch
 0003-cgroup-implement-generic-child-descendant-walk-macro.patch
 0004-cgroup_freezer-trivial-cleanups.patch
 0005-cgroup_freezer-prepare-freezer_change_state-for-full.patch
 0006-cgroup_freezer-make-freezer-state-mask-of-flags.patch
 0007-cgroup_freezer-introduce-CGROUP_FREEZING_-SELF-PAREN.patch
 0008-cgroup_freezer-add-post_create-and-pre_destroy-and-t.patch
 0009-cgroup_freezer-implement-proper-hierarchy-support.patch

0001-0003 implement cgroup descendant iterators.

0004-0008 prepare cgroup_freezer for hierarchy support.  0009
implements it.

This patchset is on top of

 v3.6 (a0d271cbfe)
+ [2] the first three patches of
  "memcg/cgroup: do not fail fail on pre_destroy callbacks" patchset
+ [3] "cgroup: simplify cgroup removal path" v2 patchset

with cgroup/for-3.8 pulled into it.  The branch is rather floaty at
the moment so it would be the easiest to pull the following branch for
review.

 git://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git 
review-cgroup_freezer-hierarchy

Thanks.

 kernel/cgroup.c |  106 +-
 kernel/cgroup_freezer.c |  359 +++-
 3 files changed, 445 insertions(+), 104 deletions(-)

--
tejun

[1] http://thread.gmane.org/gmane.linux.kernel.containers/23698
[2] http://thread.gmane.org/gmane.linux.kernel.cgroups/4757
[3] http://thread.gmane.org/gmane.linux.kernel.cgroups/4861
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/9] cgroup: add cgroup_subsys->post_create()

2012-11-03 Thread Tejun Heo
Currently, there's no way for a controller to find out whether a new
cgroup finished all ->create() allocatinos successfully and is
considered "live" by cgroup.

This becomes a problem later when we add generic descendants walking
to cgroup which can be used by controllers as controllers don't have a
synchronization point where it can synchronize against new cgroups
appearing in such walks.

This patch adds ->post_create().  It's called after all ->create()
succeeded and the cgroup is linked into the generic cgroup hierarchy.
This plays the counterpart of ->pre_destroy().

Signed-off-by: Tejun Heo 
Cc: Glauber Costa 
---
 include/linux/cgroup.h |  1 +
 kernel/cgroup.c| 12 ++--
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index fe876a7..b442122 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -438,6 +438,7 @@ int cgroup_taskset_size(struct cgroup_taskset *tset);
 
 struct cgroup_subsys {
struct cgroup_subsys_state *(*create)(struct cgroup *cgrp);
+   void (*post_create)(struct cgroup *cgrp);
void (*pre_destroy)(struct cgroup *cgrp);
void (*destroy)(struct cgroup *cgrp);
int (*can_attach)(struct cgroup *cgrp, struct cgroup_taskset *tset);
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index e3045ad..f05d992 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -4060,10 +4060,15 @@ static long cgroup_create(struct cgroup *parent, struct 
dentry *dentry,
if (err < 0)
goto err_remove;
 
-   /* each css holds a ref to the cgroup's dentry */
-   for_each_subsys(root, ss)
+   for_each_subsys(root, ss) {
+   /* each css holds a ref to the cgroup's dentry */
dget(dentry);
 
+   /* creation succeeded, notify subsystems */
+   if (ss->post_create)
+   ss->post_create(cgrp);
+   }
+
/* The cgroup directory was pre-locked for us */
BUG_ON(!mutex_is_locked(&cgrp->dentry->d_inode->i_mutex));
 
@@ -4281,6 +4286,9 @@ static void __init cgroup_init_subsys(struct 
cgroup_subsys *ss)
 
ss->active = 1;
 
+   if (ss->post_create)
+   ss->post_create(&ss->root->top_cgroup);
+
/* this function shouldn't be used with modular subsystems, since they
 * need to register a subsys_id, among other things */
BUG_ON(ss->module);
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/9] cgroup: Use rculist ops for cgroup->children

2012-11-03 Thread Tejun Heo
Use RCU safe list operations for cgroup->children.  This will be used
to implement cgroup children / descendant walking which can be used by
controllers.

Note that cgroup_create() now puts a new cgroup at the end of the
->children list instead of head.  This isn't strictly necessary but is
done so that the iteration order is more conventional.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup.h | 1 +
 kernel/cgroup.c| 8 +++-
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index b442122..90c33eb 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index f05d992..cc5d2a0 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -1650,7 +1650,6 @@ static struct dentry *cgroup_mount(struct 
file_system_type *fs_type,
 
free_cg_links(&tmp_cg_links);
 
-   BUG_ON(!list_empty(&root_cgrp->sibling));
BUG_ON(!list_empty(&root_cgrp->children));
BUG_ON(root->number_of_cgroups != 1);
 
@@ -1699,7 +1698,6 @@ static void cgroup_kill_sb(struct super_block *sb) {
 
BUG_ON(root->number_of_cgroups != 1);
BUG_ON(!list_empty(&cgrp->children));
-   BUG_ON(!list_empty(&cgrp->sibling));
 
mutex_lock(&cgroup_mutex);
mutex_lock(&cgroup_root_mutex);
@@ -4053,7 +4051,7 @@ static long cgroup_create(struct cgroup *parent, struct 
dentry *dentry,
}
}
 
-   list_add(&cgrp->sibling, &cgrp->parent->children);
+   list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children);
root->number_of_cgroups++;
 
err = cgroup_create_dir(cgrp, dentry, mode);
@@ -4084,7 +4082,7 @@ static long cgroup_create(struct cgroup *parent, struct 
dentry *dentry,
 
  err_remove:
 
-   list_del(&cgrp->sibling);
+   list_del_rcu(&cgrp->sibling);
root->number_of_cgroups--;
 
  err_destroy:
@@ -4210,7 +4208,7 @@ static int cgroup_rmdir(struct inode *unused_dir, struct 
dentry *dentry)
raw_spin_unlock(&release_list_lock);
 
/* delete this cgroup from parent->children */
-   list_del_init(&cgrp->sibling);
+   list_del_rcu(&cgrp->sibling);
 
list_del_init(&cgrp->allcg_node);
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/9] cgroup_freezer: introduce CGROUP_FREEZING_[SELF|PARENT]

2012-11-03 Thread Tejun Heo
Introduce FREEZING_SELF and FREEZING_PARENT and make FREEZING OR of
the two flags.  This is to prepare for full hierarchy support.

freezer_apply_date() is updated such that it can handle setting and
clearing of both flags.  The two flags are also exposed to userland
via read-only files self_freezing and parent_freezing.

Other than the added cgroupfs files, this patch doesn't introduce any
behavior change.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup_freezer.c | 55 ++---
 1 file changed, 47 insertions(+), 8 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index e76aa9f..b8ad93c 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -23,8 +23,12 @@
 #include 
 
 enum freezer_state_flags {
-   CGROUP_FREEZING = (1 << 1), /* this freezer is freezing */
+   CGROUP_FREEZING_SELF= (1 << 1), /* this freezer is freezing */
+   CGROUP_FREEZING_PARENT  = (1 << 2), /* the parent freezer is freezing */
CGROUP_FROZEN   = (1 << 3), /* this and its descendants frozen 
*/
+
+   /* mask for all FREEZING flags */
+   CGROUP_FREEZING = CGROUP_FREEZING_SELF | CGROUP_FREEZING_PARENT,
 };
 
 struct freezer {
@@ -245,8 +249,13 @@ static void unfreeze_cgroup(struct freezer *freezer)
  * freezer_apply_state - apply state change to a single cgroup_freezer
  * @freezer: freezer to apply state change to
  * @freeze: whether to freeze or unfreeze
+ * @state: CGROUP_FREEZING_* flag to set or clear
+ *
+ * Set or clear @state on @cgroup according to @freeze, and perform
+ * freezing or thawing as necessary.
  */
-static void freezer_apply_state(struct freezer *freezer, bool freeze)
+static void freezer_apply_state(struct freezer *freezer, bool freeze,
+   unsigned int state)
 {
/* also synchronizes against task migration, see freezer_attach() */
lockdep_assert_held(&freezer->lock);
@@ -254,13 +263,19 @@ static void freezer_apply_state(struct freezer *freezer, 
bool freeze)
if (freeze) {
if (!(freezer->state & CGROUP_FREEZING))
atomic_inc(&system_freezing_cnt);
-   freezer->state |= CGROUP_FREEZING;
+   freezer->state |= state;
freeze_cgroup(freezer);
} else {
-   if (freezer->state & CGROUP_FREEZING)
-   atomic_dec(&system_freezing_cnt);
-   freezer->state &= ~(CGROUP_FREEZING | CGROUP_FROZEN);
-   unfreeze_cgroup(freezer);
+   bool was_freezing = freezer->state & CGROUP_FREEZING;
+
+   freezer->state &= ~state;
+
+   if (!(freezer->state & CGROUP_FREEZING)) {
+   if (was_freezing)
+   atomic_dec(&system_freezing_cnt);
+   freezer->state &= ~CGROUP_FROZEN;
+   unfreeze_cgroup(freezer);
+   }
}
 }
 
@@ -275,7 +290,7 @@ static void freezer_change_state(struct freezer *freezer, 
bool freeze)
 {
/* update @freezer */
spin_lock_irq(&freezer->lock);
-   freezer_apply_state(freezer, freeze);
+   freezer_apply_state(freezer, freeze, CGROUP_FREEZING_SELF);
spin_unlock_irq(&freezer->lock);
 }
 
@@ -295,6 +310,20 @@ static int freezer_write(struct cgroup *cgroup, struct 
cftype *cft,
return 0;
 }
 
+static u64 freezer_self_freezing_read(struct cgroup *cgroup, struct cftype 
*cft)
+{
+   struct freezer *freezer = cgroup_freezer(cgroup);
+
+   return (bool)(freezer->state & CGROUP_FREEZING_SELF);
+}
+
+static u64 freezer_parent_freezing_read(struct cgroup *cgroup, struct cftype 
*cft)
+{
+   struct freezer *freezer = cgroup_freezer(cgroup);
+
+   return (bool)(freezer->state & CGROUP_FREEZING_PARENT);
+}
+
 static struct cftype files[] = {
{
.name = "state",
@@ -302,6 +331,16 @@ static struct cftype files[] = {
.read_seq_string = freezer_read,
.write_string = freezer_write,
},
+   {
+   .name = "self_freezing",
+   .flags = CFTYPE_NOT_ON_ROOT,
+   .read_u64 = freezer_self_freezing_read,
+   },
+   {
+   .name = "parent_freezing",
+   .flags = CFTYPE_NOT_ON_ROOT,
+   .read_u64 = freezer_parent_freezing_read,
+   },
{ } /* terminate */
 };
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 9/9] cgroup_freezer: implement proper hierarchy support

2012-11-03 Thread Tejun Heo
Up until now, cgroup_freezer didn't implement hierarchy properly.
cgroups could be arranged in hierarchy but it didn't make any
difference in how each cgroup_freezer behaved.  They all operated
separately.

This patch implements proper hierarchy support.  If a cgroup is
frozen, all its descendants are frozen.  A cgroup is thawed iff it and
all its ancestors are THAWED.  freezer.self_freezing shows the current
freezing state for the cgroup itself.  freezer.parent_freezing shows
whether the cgroup is freezing because any of its ancestors is
freezing.

freezer_post_create() locks the parent and new cgroup and inherits the
parent's state and freezer_change_state() applies new state top-down
using cgroup_for_each_descendant_pre() which guarantees that no child
can escape its parent's state.  update_if_frozen() uses
cgroup_for_each_descendant_post() to propagate frozen states
bottom-up.

Synchronization could be coarser and easier by using a single mutex to
protect all hierarchy operations.  Finer grained approach was used
because it wasn't too difficult for cgroup_freezer and I think it's
beneficial to have an example implementation and cgroup_freezer is
rather simple and can serve a good one.

As this makes cgroup_freezer properly hierarchical,
freezer_subsys.broken_hierarchy marking is removed.

Note that this patch changes userland visible behavior - freezing a
cgroup now freezes all its descendants too.  This behavior change is
intended and has been warned via .broken_hierarchy.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup_freezer.c | 161 
 1 file changed, 123 insertions(+), 38 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 4f12d31..3262537 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -22,6 +22,13 @@
 #include 
 #include 
 
+/*
+ * A cgroup is freezing if any FREEZING flags are set.  FREEZING_SELF is
+ * set if "FROZEN" is written to freezer.state cgroupfs file, and cleared
+ * for "THAWED".  FREEZING_PARENT is set if the parent freezer is FREEZING
+ * for whatever reason.  IOW, a cgroup has FREEZING_PARENT set if one of
+ * its ancestors has FREEZING_SELF set.
+ */
 enum freezer_state_flags {
CGROUP_FREEZER_ONLINE   = (1 << 0), /* freezer is fully online */
CGROUP_FREEZING_SELF= (1 << 1), /* this freezer is freezing */
@@ -50,6 +57,15 @@ static inline struct freezer *task_freezer(struct 
task_struct *task)
struct freezer, css);
 }
 
+static struct freezer *parent_freezer(struct freezer *freezer)
+{
+   struct cgroup *pcg = freezer->css.cgroup->parent;
+
+   if (pcg)
+   return cgroup_freezer(pcg);
+   return NULL;
+}
+
 bool cgroup_freezing(struct task_struct *task)
 {
bool ret;
@@ -74,17 +90,6 @@ static const char *freezer_state_strs(unsigned int state)
return "THAWED";
 };
 
-/*
- * State diagram
- * Transitions are caused by userspace writes to the freezer.state file.
- * The values in parenthesis are state labels. The rest are edge labels.
- *
- * (THAWED) --FROZEN--> (FREEZING) --FROZEN--> (FROZEN)
- *^ ^| |
- *| \___THAWED___/ |
- *\__THAWED/
- */
-
 struct cgroup_subsys freezer_subsys;
 
 static struct cgroup_subsys_state *freezer_create(struct cgroup *cgroup)
@@ -103,15 +108,34 @@ static struct cgroup_subsys_state *freezer_create(struct 
cgroup *cgroup)
  * freezer_post_create - commit creation of a freezer cgroup
  * @cgroup: cgroup being created
  *
- * We're committing to creation of @cgroup.  Mark it online.
+ * We're committing to creation of @cgroup.  Mark it online and inherit
+ * parent's freezing state while holding both parent's and our
+ * freezer->lock.
  */
 static void freezer_post_create(struct cgroup *cgroup)
 {
struct freezer *freezer = cgroup_freezer(cgroup);
+   struct freezer *parent = parent_freezer(freezer);
+
+   /*
+* The following double locking and freezing state inheritance
+* guarantee that @cgroup can never escape ancestors' freezing
+* states.  See cgroup_for_each_descendant_pre() for details.
+*/
+   if (parent)
+   spin_lock_irq(&parent->lock);
+   spin_lock_nested(&freezer->lock, SINGLE_DEPTH_NESTING);
 
-   spin_lock_irq(&freezer->lock);
freezer->state |= CGROUP_FREEZER_ONLINE;
-   spin_unlock_irq(&freezer->lock);
+
+   if (parent && (parent->state & CGROUP_FREEZING)) {
+   freezer->state |= CGROUP_FREEZING_PARENT | CGROUP_FROZEN;
+   atomic_inc(&system_freezing_cnt);
+   }
+
+   spin_unlock(&freezer->lock);
+   if (parent)
+   spin_unlock_irq(&parent->lock);
 }
 
 /**
@@ -153,6 +177,7 @@ static void freezer_attach(struct cgroup *new_cgrp, struct 
cgroup_taskset *tset)
 {
struct freezer *freezer = cgroup_freezer(new

[PATCH 5/9] cgroup_freezer: prepare freezer_change_state() for full hierarchy support

2012-11-03 Thread Tejun Heo
* Make freezer_change_state() take bool @freeze instead of enum
  freezer_state.

* Separate out freezer_apply_state() out of freezer_change_state().
  This makes freezer_change_state() a rather silly thin wrapper.  It
  will be filled with hierarchy handling later on.

This patch doesn't introduce any behavior change.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup_freezer.c | 48 ++--
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 975b3d8..2690830 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -247,45 +247,57 @@ static void unfreeze_cgroup(struct freezer *freezer)
cgroup_iter_end(cgroup, &it);
 }
 
-static void freezer_change_state(struct freezer *freezer,
-enum freezer_state goal_state)
+/**
+ * freezer_apply_state - apply state change to a single cgroup_freezer
+ * @freezer: freezer to apply state change to
+ * @freeze: whether to freeze or unfreeze
+ */
+static void freezer_apply_state(struct freezer *freezer, bool freeze)
 {
/* also synchronizes against task migration, see freezer_attach() */
-   spin_lock_irq(&freezer->lock);
+   lockdep_assert_held(&freezer->lock);
 
-   switch (goal_state) {
-   case CGROUP_THAWED:
-   if (freezer->state != CGROUP_THAWED)
-   atomic_dec(&system_freezing_cnt);
-   freezer->state = CGROUP_THAWED;
-   unfreeze_cgroup(freezer);
-   break;
-   case CGROUP_FROZEN:
+   if (freeze) {
if (freezer->state == CGROUP_THAWED)
atomic_inc(&system_freezing_cnt);
freezer->state = CGROUP_FREEZING;
freeze_cgroup(freezer);
-   break;
-   default:
-   BUG();
+   } else {
+   if (freezer->state != CGROUP_THAWED)
+   atomic_dec(&system_freezing_cnt);
+   freezer->state = CGROUP_THAWED;
+   unfreeze_cgroup(freezer);
}
+}
 
+/**
+ * freezer_change_state - change the freezing state of a cgroup_freezer
+ * @freezer: freezer of interest
+ * @freeze: whether to freeze or thaw
+ *
+ * Freeze or thaw @cgroup according to @freeze.
+ */
+static void freezer_change_state(struct freezer *freezer, bool freeze)
+{
+   /* update @freezer */
+   spin_lock_irq(&freezer->lock);
+   freezer_apply_state(freezer, freeze);
spin_unlock_irq(&freezer->lock);
 }
 
 static int freezer_write(struct cgroup *cgroup, struct cftype *cft,
 const char *buffer)
 {
-   enum freezer_state goal_state;
+   bool freeze;
 
if (strcmp(buffer, freezer_state_strs[CGROUP_THAWED]) == 0)
-   goal_state = CGROUP_THAWED;
+   freeze = false;
else if (strcmp(buffer, freezer_state_strs[CGROUP_FROZEN]) == 0)
-   goal_state = CGROUP_FROZEN;
+   freeze = true;
else
return -EINVAL;
 
-   freezer_change_state(cgroup_freezer(cgroup), goal_state);
+   freezer_change_state(cgroup_freezer(cgroup), freeze);
return 0;
 }
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/9] cgroup_freezer: trivial cleanups

2012-11-03 Thread Tejun Heo
* Clean-up indentation and line-breaks.  Drop the invalid comment
  about freezer->lock.

* Make all internal functions take @freezer instead of both @cgroup
  and @freezer.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup_freezer.c | 41 +++--
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index bedefd9..975b3d8 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -29,17 +29,15 @@ enum freezer_state {
 };
 
 struct freezer {
-   struct cgroup_subsys_state css;
-   enum freezer_state state;
-   spinlock_t lock; /* protects _writes_ to state */
+   struct cgroup_subsys_state  css;
+   enum freezer_state  state;
+   spinlock_t  lock;
 };
 
-static inline struct freezer *cgroup_freezer(
-   struct cgroup *cgroup)
+static inline struct freezer *cgroup_freezer(struct cgroup *cgroup)
 {
-   return container_of(
-   cgroup_subsys_state(cgroup, freezer_subsys_id),
-   struct freezer, css);
+   return container_of(cgroup_subsys_state(cgroup, freezer_subsys_id),
+   struct freezer, css);
 }
 
 static inline struct freezer *task_freezer(struct task_struct *task)
@@ -180,8 +178,9 @@ out:
  * migrated into or out of @cgroup, so we can't verify task states against
  * @freezer state here.  See freezer_attach() for details.
  */
-static void update_if_frozen(struct cgroup *cgroup, struct freezer *freezer)
+static void update_if_frozen(struct freezer *freezer)
 {
+   struct cgroup *cgroup = freezer->css.cgroup;
struct cgroup_iter it;
struct task_struct *task;
 
@@ -211,12 +210,11 @@ notyet:
 static int freezer_read(struct cgroup *cgroup, struct cftype *cft,
struct seq_file *m)
 {
-   struct freezer *freezer;
+   struct freezer *freezer = cgroup_freezer(cgroup);
enum freezer_state state;
 
-   freezer = cgroup_freezer(cgroup);
spin_lock_irq(&freezer->lock);
-   update_if_frozen(cgroup, freezer);
+   update_if_frozen(freezer);
state = freezer->state;
spin_unlock_irq(&freezer->lock);
 
@@ -225,8 +223,9 @@ static int freezer_read(struct cgroup *cgroup, struct 
cftype *cft,
return 0;
 }
 
-static void freeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
+static void freeze_cgroup(struct freezer *freezer)
 {
+   struct cgroup *cgroup = freezer->css.cgroup;
struct cgroup_iter it;
struct task_struct *task;
 
@@ -236,8 +235,9 @@ static void freeze_cgroup(struct cgroup *cgroup, struct 
freezer *freezer)
cgroup_iter_end(cgroup, &it);
 }
 
-static void unfreeze_cgroup(struct cgroup *cgroup, struct freezer *freezer)
+static void unfreeze_cgroup(struct freezer *freezer)
 {
+   struct cgroup *cgroup = freezer->css.cgroup;
struct cgroup_iter it;
struct task_struct *task;
 
@@ -247,11 +247,9 @@ static void unfreeze_cgroup(struct cgroup *cgroup, struct 
freezer *freezer)
cgroup_iter_end(cgroup, &it);
 }
 
-static void freezer_change_state(struct cgroup *cgroup,
+static void freezer_change_state(struct freezer *freezer,
 enum freezer_state goal_state)
 {
-   struct freezer *freezer = cgroup_freezer(cgroup);
-
/* also synchronizes against task migration, see freezer_attach() */
spin_lock_irq(&freezer->lock);
 
@@ -260,13 +258,13 @@ static void freezer_change_state(struct cgroup *cgroup,
if (freezer->state != CGROUP_THAWED)
atomic_dec(&system_freezing_cnt);
freezer->state = CGROUP_THAWED;
-   unfreeze_cgroup(cgroup, freezer);
+   unfreeze_cgroup(freezer);
break;
case CGROUP_FROZEN:
if (freezer->state == CGROUP_THAWED)
atomic_inc(&system_freezing_cnt);
freezer->state = CGROUP_FREEZING;
-   freeze_cgroup(cgroup, freezer);
+   freeze_cgroup(freezer);
break;
default:
BUG();
@@ -275,8 +273,7 @@ static void freezer_change_state(struct cgroup *cgroup,
spin_unlock_irq(&freezer->lock);
 }
 
-static int freezer_write(struct cgroup *cgroup,
-struct cftype *cft,
+static int freezer_write(struct cgroup *cgroup, struct cftype *cft,
 const char *buffer)
 {
enum freezer_state goal_state;
@@ -288,7 +285,7 @@ static int freezer_write(struct cgroup *cgroup,
else
return -EINVAL;
 
-   freezer_change_state(cgroup, goal_state);
+   freezer_change_state(cgroup_freezer(cgroup), goal_state);
return 0;
 }
 
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel

[PATCH 8/9] cgroup_freezer: add ->post_create() and ->pre_destroy() and track online state

2012-11-03 Thread Tejun Heo
A cgroup is online and visible to iteration between ->post_create()
and ->pre_destroy().  This patch introduces CGROUP_FREEZER_ONLINE and
toggles it from the newly added freezer_post_create() and
freezer_pre_destroy() while holding freezer->lock such that a
cgroup_freezer can be reilably distinguished to be online.  This will
be used by full hierarchy support.

ONLINE test is added to freezer_apply_state() but it currently doesn't
make any difference as freezer_write() can only be called for an
online cgroup.

Adjusting system_freezing_cnt on destruction is moved from
freezer_destroy() to the new freezer_pre_destroy() for consistency.

This patch doesn't introduce any noticeable behavior change.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup_freezer.c | 42 --
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index b8ad93c..4f12d31 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -23,6 +23,7 @@
 #include 
 
 enum freezer_state_flags {
+   CGROUP_FREEZER_ONLINE   = (1 << 0), /* freezer is fully online */
CGROUP_FREEZING_SELF= (1 << 1), /* this freezer is freezing */
CGROUP_FREEZING_PARENT  = (1 << 2), /* the parent freezer is freezing */
CGROUP_FROZEN   = (1 << 3), /* this and its descendants frozen 
*/
@@ -98,13 +99,45 @@ static struct cgroup_subsys_state *freezer_create(struct 
cgroup *cgroup)
return &freezer->css;
 }
 
-static void freezer_destroy(struct cgroup *cgroup)
+/**
+ * freezer_post_create - commit creation of a freezer cgroup
+ * @cgroup: cgroup being created
+ *
+ * We're committing to creation of @cgroup.  Mark it online.
+ */
+static void freezer_post_create(struct cgroup *cgroup)
 {
struct freezer *freezer = cgroup_freezer(cgroup);
 
+   spin_lock_irq(&freezer->lock);
+   freezer->state |= CGROUP_FREEZER_ONLINE;
+   spin_unlock_irq(&freezer->lock);
+}
+
+/**
+ * freezer_pre_destroy - initiate destruction of @cgroup
+ * @cgroup: cgroup being destroyed
+ *
+ * @cgroup is going away.  Mark it dead and decrement system_freezing_count
+ * if it was holding one.
+ */
+static void freezer_pre_destroy(struct cgroup *cgroup)
+{
+   struct freezer *freezer = cgroup_freezer(cgroup);
+
+   spin_lock_irq(&freezer->lock);
+
if (freezer->state & CGROUP_FREEZING)
atomic_dec(&system_freezing_cnt);
-   kfree(freezer);
+
+   freezer->state = 0;
+
+   spin_unlock_irq(&freezer->lock);
+}
+
+static void freezer_destroy(struct cgroup *cgroup)
+{
+   kfree(cgroup_freezer(cgroup));
 }
 
 /*
@@ -260,6 +293,9 @@ static void freezer_apply_state(struct freezer *freezer, 
bool freeze,
/* also synchronizes against task migration, see freezer_attach() */
lockdep_assert_held(&freezer->lock);
 
+   if (!(freezer->state & CGROUP_FREEZER_ONLINE))
+   return;
+
if (freeze) {
if (!(freezer->state & CGROUP_FREEZING))
atomic_inc(&system_freezing_cnt);
@@ -347,6 +383,8 @@ static struct cftype files[] = {
 struct cgroup_subsys freezer_subsys = {
.name   = "freezer",
.create = freezer_create,
+   .post_create= freezer_post_create,
+   .pre_destroy= freezer_pre_destroy,
.destroy= freezer_destroy,
.subsys_id  = freezer_subsys_id,
.attach = freezer_attach,
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/9] cgroup_freezer: make freezer->state mask of flags

2012-11-03 Thread Tejun Heo
freezer->state was an enum value - one of THAWED, FREEZING and FROZEN.
As the scheduled full hierarchy support requires more than one
freezing condition, switch it to mask of flags.  If FREEZING is not
set, it's thawed.  FREEZING is set if freezing or frozen.  If frozen,
both FREEZING and FROZEN are set.  Now that tasks can be attached to
an already frozen cgroup, this also makes freezing condition checks
more natural.

This patch doesn't introduce any behavior change.

Signed-off-by: Tejun Heo 
---
 kernel/cgroup_freezer.c | 60 ++---
 1 file changed, 27 insertions(+), 33 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index 2690830..e76aa9f 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -22,15 +22,14 @@
 #include 
 #include 
 
-enum freezer_state {
-   CGROUP_THAWED = 0,
-   CGROUP_FREEZING,
-   CGROUP_FROZEN,
+enum freezer_state_flags {
+   CGROUP_FREEZING = (1 << 1), /* this freezer is freezing */
+   CGROUP_FROZEN   = (1 << 3), /* this and its descendants frozen 
*/
 };
 
 struct freezer {
struct cgroup_subsys_state  css;
-   enum freezer_state  state;
+   unsigned intstate;
spinlock_t  lock;
 };
 
@@ -48,12 +47,10 @@ static inline struct freezer *task_freezer(struct 
task_struct *task)
 
 bool cgroup_freezing(struct task_struct *task)
 {
-   enum freezer_state state;
bool ret;
 
rcu_read_lock();
-   state = task_freezer(task)->state;
-   ret = state == CGROUP_FREEZING || state == CGROUP_FROZEN;
+   ret = task_freezer(task)->state & CGROUP_FREEZING;
rcu_read_unlock();
 
return ret;
@@ -63,10 +60,13 @@ bool cgroup_freezing(struct task_struct *task)
  * cgroups_write_string() limits the size of freezer state strings to
  * CGROUP_LOCAL_BUFFER_SIZE
  */
-static const char *freezer_state_strs[] = {
-   "THAWED",
-   "FREEZING",
-   "FROZEN",
+static const char *freezer_state_strs(unsigned int state)
+{
+   if (state & CGROUP_FROZEN)
+   return "FROZEN";
+   if (state & CGROUP_FREEZING)
+   return "FREEZING";
+   return "THAWED";
 };
 
 /*
@@ -91,7 +91,6 @@ static struct cgroup_subsys_state *freezer_create(struct 
cgroup *cgroup)
return ERR_PTR(-ENOMEM);
 
spin_lock_init(&freezer->lock);
-   freezer->state = CGROUP_THAWED;
return &freezer->css;
 }
 
@@ -99,7 +98,7 @@ static void freezer_destroy(struct cgroup *cgroup)
 {
struct freezer *freezer = cgroup_freezer(cgroup);
 
-   if (freezer->state != CGROUP_THAWED)
+   if (freezer->state & CGROUP_FREEZING)
atomic_dec(&system_freezing_cnt);
kfree(freezer);
 }
@@ -129,15 +128,13 @@ static void freezer_attach(struct cgroup *new_cgrp, 
struct cgroup_taskset *tset)
 * Tasks in @tset are on @new_cgrp but may not conform to its
 * current state before executing the following - !frozen tasks may
 * be visible in a FROZEN cgroup and frozen tasks in a THAWED one.
-* This means that, to determine whether to freeze, one should test
-* whether the state equals THAWED.
 */
cgroup_taskset_for_each(task, new_cgrp, tset) {
-   if (freezer->state == CGROUP_THAWED) {
+   if (!(freezer->state & CGROUP_FREEZING)) {
__thaw_task(task);
} else {
freeze_task(task);
-   freezer->state = CGROUP_FREEZING;
+   freezer->state &= ~CGROUP_FROZEN;
}
}
 
@@ -159,11 +156,7 @@ static void freezer_fork(struct task_struct *task)
goto out;
 
spin_lock_irq(&freezer->lock);
-   /*
-* @task might have been just migrated into a FROZEN cgroup.  Test
-* equality with THAWED.  Read the comment in freezer_attach().
-*/
-   if (freezer->state != CGROUP_THAWED)
+   if (freezer->state & CGROUP_FREEZING)
freeze_task(task);
spin_unlock_irq(&freezer->lock);
 out:
@@ -184,7 +177,8 @@ static void update_if_frozen(struct freezer *freezer)
struct cgroup_iter it;
struct task_struct *task;
 
-   if (freezer->state != CGROUP_FREEZING)
+   if (!(freezer->state & CGROUP_FREEZING) ||
+   (freezer->state & CGROUP_FROZEN))
return;
 
cgroup_iter_start(cgroup, &it);
@@ -202,7 +196,7 @@ static void update_if_frozen(struct freezer *freezer)
}
}
 
-   freezer->state = CGROUP_FROZEN;
+   freezer->state |= CGROUP_FROZEN;
 notyet:
cgroup_iter_end(cgroup, &it);
 }
@@ -211,14 +205,14 @@ static int freezer_read(struct cgroup *cgroup, struct 
cftype *cft,
struct seq_file *m)
 {
struct freezer *freezer = cgroup_freezer(cgroup);
-   enum freezer_

[PATCH 3/9] cgroup: implement generic child / descendant walk macros

2012-11-03 Thread Tejun Heo
Currently, cgroup doesn't provide any generic helper for walking a
given cgroup's children or descendants.  This patch adds the following
three macros.

* cgroup_for_each_child() - walk immediate children of a cgroup.

* cgroup_for_each_descendant_pre() - visit all descendants of a cgroup
  in pre-order tree traversal.

* cgroup_for_each_descendant_post() - visit all descendants of a
  cgroup in post-order tree traversal.

All three only require the user to hold RCU read lock during
traversal.  Verifying that each iterated cgroup is online is the
responsibility of the user.  When used with proper synchronization,
cgroup_for_each_descendant_pre() can be used to propagate config
updates to descendants in reliable way.  See comments for details.

Signed-off-by: Tejun Heo 
---
 include/linux/cgroup.h | 82 +++
 kernel/cgroup.c| 86 ++
 2 files changed, 168 insertions(+)

diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h
index 90c33eb..0020329 100644
--- a/include/linux/cgroup.h
+++ b/include/linux/cgroup.h
@@ -534,6 +534,88 @@ static inline struct cgroup* task_cgroup(struct 
task_struct *task,
return task_subsys_state(task, subsys_id)->cgroup;
 }
 
+/**
+ * cgroup_for_each_child - iterate through children of a cgroup
+ * @pos: the cgroup * to use as the loop cursor
+ * @cgroup: cgroup whose children to walk
+ *
+ * Walk @cgroup's children.  Must be called under rcu_read_lock().  A child
+ * cgroup which hasn't finished ->post_create() or already has finished
+ * ->pre_destroy() may show up during traversal and it's each subsystem's
+ * responsibility to verify that each @pos is alive.
+ *
+ * If a subsystem synchronizes against the parent in its ->post_create()
+ * and before starting iterating, a cgroup which finished ->post_create()
+ * is guaranteed to be visible in the future iterations.
+ */
+#define cgroup_for_each_child(pos, cgroup) \
+   list_for_each_entry_rcu(pos, &(cgroup)->children, sibling)
+
+struct cgroup *cgroup_next_descendant_pre(struct cgroup *pos,
+ struct cgroup *cgroup);
+
+/**
+ * cgroup_for_each_descendant_pre - pre-order walk of a cgroup's descendants
+ * @pos: the cgroup * to use as the loop cursor
+ * @cgroup: cgroup whose descendants to walk
+ *
+ * Walk @cgroup's descendants.  Must be called under rcu_read_lock().  A
+ * descendant cgroup which hasn't finished ->post_create() or already has
+ * finished ->pre_destroy() may show up during traversal and it's each
+ * subsystem's responsibility to verify that each @pos is alive.
+ *
+ * If a subsystem synchronizes against the parent in its ->post_create()
+ * and before starting iterating, and synchronizes against @pos on each
+ * iteration, any descendant cgroup which finished ->post_create() is
+ * guaranteed to be visible in the future iterations.
+ *
+ * In other words, the following guarantees that a descendant can't escape
+ * configuration of its ancestors.
+ *
+ * my_post_create(@cgrp)
+ * {
+ * Lock @cgrp->parent and @cgrp;
+ * Inherit config from @cgrp->parent;
+ * Unlock both.
+ * }
+ *
+ * my_update_config(@cgrp)
+ * {
+ * Lock @cgrp;
+ * Update @cgrp's config;
+ * Unlock @cgrp;
+ *
+ * cgroup_for_each_descendant_pre(@pos, @cgrp) {
+ * Lock @pos;
+ * Verify @pos is alive and inherit config from @pos->parent;
+ * Unlock @pos;
+ * }
+ * }
+ *
+ * Alternatively, a subsystem may choose to use a single global lock to
+ * synchronize ->post_create() and ->pre_destroy() against tree-walking
+ * operations.
+ */
+#define cgroup_for_each_descendant_pre(pos, cgroup)\
+   for (pos = cgroup_next_descendant_pre(NULL, (cgroup)); (pos);   \
+pos = cgroup_next_descendant_pre((pos), (cgroup)))
+
+struct cgroup *cgroup_next_descendant_post(struct cgroup *pos,
+  struct cgroup *cgroup);
+
+/**
+ * cgroup_for_each_descendant_post - post-order walk of a cgroup's descendants
+ * @pos: the cgroup * to use as the loop cursor
+ * @cgroup: cgroup whose descendants to walk
+ *
+ * Similar to cgroup_for_each_descendant_pre() but performs post-order
+ * traversal instead.  Note that the walk visibility guarantee described in
+ * pre-order walk doesn't apply the same to post-order walks.
+ */
+#define cgroup_for_each_descendant_post(pos, cgroup)   \
+   for (pos = cgroup_next_descendant_post(NULL, (cgroup)); (pos);  \
+pos = cgroup_next_descendant_post((pos), (cgroup)))
+
 /* A cgroup_iter should be treated as an opaque object */
 struct cgroup_iter {
struct list_head *cg_link;
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index cc5d2a0..8bd662c 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2985,6 +2985,92 @@ static void cgroup_enable_task_cg_lists(void)
write_unlock(&

[PATCH] IRQ CORE: irq_work_queue function return value not used.

2012-11-03 Thread anish kumar
From: anish kumar 

As no one is using the return value of irq_work_queue function
it is better to just make it void.

Acked-by: Steven Rostedt 
Signed-off-by: anish kumar 
---
 kernel/irq_work.c |5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/irq_work.c b/kernel/irq_work.c
index 1588e3b..4829a31 100644
--- a/kernel/irq_work.c
+++ b/kernel/irq_work.c
@@ -79,17 +79,16 @@ static void __irq_work_queue(struct irq_work *work)
  *
  * Can be re-enqueued while the callback is still in progress.
  */
-bool irq_work_queue(struct irq_work *work)
+void irq_work_queue(struct irq_work *work)
 {
if (!irq_work_claim(work)) {
/*
 * Already enqueued, can't do!
 */
-   return false;
+   return;
}
 
__irq_work_queue(work);
-   return true;
 }
 EXPORT_SYMBOL_GPL(irq_work_queue);
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2 6/9] rcu: use __this_cpu_read helper instead of per_cpu_ptr(p, raw_smp_processor_id())

2012-11-03 Thread Paul E. McKenney
On Fri, Nov 02, 2012 at 08:19:04PM +, Christoph Lameter wrote:
> On Fri, 2 Nov 2012, Paul E. McKenney wrote:
> 
> > On Sat, Nov 03, 2012 at 12:01:47AM +0800, Shan Wei wrote:
> > > From: Shan Wei 
> > >
> > > Signed-off-by: Shan Wei 
> > > ---
> > >  kernel/rcutree.c |2 +-
> > >  1 files changed, 1 insertions(+), 1 deletions(-)
> > >
> > > diff --git a/kernel/rcutree.c b/kernel/rcutree.c
> > > index 74df86b..441b945 100644
> > > --- a/kernel/rcutree.c
> > > +++ b/kernel/rcutree.c
> > > @@ -1960,7 +1960,7 @@ static void force_quiescent_state(struct rcu_state 
> > > *rsp)
> > >   struct rcu_node *rnp_old = NULL;
> > >
> > >   /* Funnel through hierarchy to reduce memory contention. */
> > > - rnp = per_cpu_ptr(rsp->rda, raw_smp_processor_id())->mynode;
> > > + rnp = __this_cpu_read(rsp->rda->mynode);
> >
> > OK, I'll bite...  Why this instead of:
> >
> > rnp = __this_cpu_read(rsp->rda)->mynode;
> 
> Because this_cpu_read fetches a data word from an address. The addres is
> relocated using a segment prefix (which contains the offset of the
> current per cpu area).
> 
> And the address needed here is the address of the field of mynode
> within a structure that has a per cpu address.

OK, I do understand why it happens to work.  My question is instead why
it is considered a good idea.  After all, it is the ->rda field that is
marked __percpu, not the ->mynode field.  So in the interest of
mechanical checking and general readability, it seems to me that it
would be way better to apply __this_cpu_read() to rsp->rda rather than
to rsp->rda->mynode.

Thanx, Paul

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 00/21 v4] drop vmtruncate

2012-11-03 Thread Marco Stornelli

Hi all,

I send the fourth patch series to remove vmtruncate. Any 
comments/feedback are welcome.


Changes:
v4: fix an error for ocfs2, silently ignore truncate for procfs as 
suggested by Al

v3: reworked after Al and Christoph comments
v2: add documentation cleaning
v1: first draft

Marco Stornelli (21):
  ufs: drop vmtruncate
  sysv: drop vmtruncate
  reiserfs: drop vmtruncate
  procfs: drop vmtruncate
  omfs: drop vmtruncate
  ocfs2: drop vmtruncate
  adfs: drop vmtruncate
  affs: drop vmtruncate
  bfs: drop vmtruncate
  hfs: drop vmtruncate
  hpfs: drop vmtruncate
  jfs: drop vmtruncate
  hfsplus: drop vmtruncate
  logfs: drop vmtruncate
  minix: drop vmtruncate
  ncpfs: drop vmtruncate
  nilfs2: drop vmtruncate
  ntfs: drop vmtruncate
  vfs: drop vmtruncate
  mm: drop vmtruncate
  documentation: drop vmtruncate

 Documentation/filesystems/Locking |6 --
 Documentation/filesystems/porting |2 +-
 Documentation/filesystems/vfs.txt |   11 ---
 fs/adfs/inode.c   |   15 ++-
 fs/affs/file.c|   18 --
 fs/affs/inode.c   |5 -
 fs/bfs/file.c |   15 ++-
 fs/hfs/inode.c|   26 ++
 fs/hfsplus/inode.c|   27 ---
 fs/hpfs/file.c|   18 --
 fs/hpfs/inode.c   |5 -
 fs/jfs/file.c |6 --
 fs/jfs/inode.c|   20 ++--
 fs/libfs.c|2 --
 fs/logfs/readwrite.c  |   10 --
 fs/minix/file.c   |6 --
 fs/minix/inode.c  |   17 -
 fs/ncpfs/inode.c  |4 +---
 fs/nilfs2/file.c  |1 -
 fs/nilfs2/inode.c |   24 +++-
 fs/nilfs2/nilfs.h |1 +
 fs/nilfs2/recovery.c  |3 ++-
 fs/ntfs/file.c|   16 +---
 fs/ntfs/inode.c   |8 ++--
 fs/ntfs/inode.h   |4 
 fs/ocfs2/file.c   |   18 --
 fs/omfs/file.c|   22 +++---
 fs/proc/base.c|7 ---
 fs/proc/generic.c |9 +
 fs/proc/proc_sysctl.c |7 ---
 fs/reiserfs/file.c|3 +--
 fs/reiserfs/inode.c   |   15 +++
 fs/reiserfs/reiserfs.h|1 +
 fs/sysv/file.c|5 +++--
 fs/sysv/itree.c   |   17 -
 fs/ufs/inode.c|   15 ++-
 include/linux/fs.h|1 -
 include/linux/mm.h|1 -
 mm/truncate.c |   23 ---
 39 files changed, 225 insertions(+), 189 deletions(-)

--
1.7.3.4
---
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 01/21] ufs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/ufs/inode.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index eb6d0b7..ff24e44 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -526,6 +526,14 @@ int ufs_prepare_chunk(struct page *page, loff_t pos, 
unsigned len)
return __block_write_begin(page, pos, len, ufs_getfrag_block);
 }
 
+static void ufs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size)
+   truncate_pagecache(inode, to, inode->i_size);
+}
+
 static int ufs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -534,11 +542,8 @@ static int ufs_write_begin(struct file *file, struct 
address_space *mapping,
 
ret = block_write_begin(mapping, pos, len, flags, pagep,
ufs_getfrag_block);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   ufs_write_failed(mapping, pos + len);
 
return ret;
 }
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 02/21] sysv: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/sysv/file.c  |5 +++--
 fs/sysv/itree.c |   17 -
 2 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/fs/sysv/file.c b/fs/sysv/file.c
index 0a65939..9d4dc68 100644
--- a/fs/sysv/file.c
+++ b/fs/sysv/file.c
@@ -41,9 +41,11 @@ static int sysv_setattr(struct dentry *dentry, struct iattr 
*attr)
 
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
+   error = inode_newsize_ok(inode, attr->ia_size);
if (error)
return error;
+   truncate_setsize(inode, attr->ia_size);
+   sysv_truncate(inode);
}
 
setattr_copy(inode, attr);
@@ -52,7 +54,6 @@ static int sysv_setattr(struct dentry *dentry, struct iattr 
*attr)
 }
 
 const struct inode_operations sysv_file_inode_operations = {
-   .truncate   = sysv_truncate,
.setattr= sysv_setattr,
.getattr= sysv_getattr,
 };
diff --git a/fs/sysv/itree.c b/fs/sysv/itree.c
index 90b54b4..c1a591a 100644
--- a/fs/sysv/itree.c
+++ b/fs/sysv/itree.c
@@ -464,6 +464,16 @@ int sysv_prepare_chunk(struct page *page, loff_t pos, 
unsigned len)
return __block_write_begin(page, pos, len, get_block);
 }
 
+static void sysv_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   sysv_truncate(inode);
+   }
+}
+
 static int sysv_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -471,11 +481,8 @@ static int sysv_write_begin(struct file *file, struct 
address_space *mapping,
int ret;
 
ret = block_write_begin(mapping, pos, len, flags, pagep, get_block);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   sysv_write_failed(mapping, pos + len);
 
return ret;
 }
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 03/21] reiserfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/reiserfs/file.c |3 +--
 fs/reiserfs/inode.c|   15 +++
 fs/reiserfs/reiserfs.h |1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/fs/reiserfs/file.c b/fs/reiserfs/file.c
index 8375c92..50302d6 100644
--- a/fs/reiserfs/file.c
+++ b/fs/reiserfs/file.c
@@ -126,7 +126,7 @@ static int reiserfs_file_open(struct inode *inode, struct 
file *file)
return err;
 }
 
-static void reiserfs_vfs_truncate_file(struct inode *inode)
+void reiserfs_vfs_truncate_file(struct inode *inode)
 {
mutex_lock(&(REISERFS_I(inode)->tailpack));
reiserfs_truncate_file(inode, 1);
@@ -312,7 +312,6 @@ const struct file_operations reiserfs_file_operations = {
 };
 
 const struct inode_operations reiserfs_file_inode_operations = {
-   .truncate = reiserfs_vfs_truncate_file,
.setattr = reiserfs_setattr,
.setxattr = reiserfs_setxattr,
.getxattr = reiserfs_getxattr,
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c
index f27f01a..ffb3993 100644
--- a/fs/reiserfs/inode.c
+++ b/fs/reiserfs/inode.c
@@ -3082,8 +3082,10 @@ static ssize_t reiserfs_direct_IO(int rw, struct kiocb 
*iocb,
loff_t isize = i_size_read(inode);
loff_t end = offset + iov_length(iov, nr_segs);
 
-   if (end > isize)
-   vmtruncate(inode, isize);
+   if ((end > isize) && inode_newsize_ok(inode, isize) == 0) {
+   truncate_setsize(inode, isize);
+   reiserfs_vfs_truncate_file(inode);
+   }
}
 
return ret;
@@ -3196,8 +3198,13 @@ int reiserfs_setattr(struct dentry *dentry, struct iattr 
*attr)
 */
reiserfs_write_unlock_once(inode->i_sb, depth);
if ((attr->ia_valid & ATTR_SIZE) &&
-   attr->ia_size != i_size_read(inode))
-   error = vmtruncate(inode, attr->ia_size);
+   attr->ia_size != i_size_read(inode)) {
+   error = inode_newsize_ok(inode, attr->ia_size);
+   if (!error) {
+   truncate_setsize(inode, attr->ia_size);
+   reiserfs_vfs_truncate_file(inode);
+   }
+   }
 
if (!error) {
setattr_copy(inode, attr);
diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
index 33215f5..157e474 100644
--- a/fs/reiserfs/reiserfs.h
+++ b/fs/reiserfs/reiserfs.h
@@ -2455,6 +2455,7 @@ struct reiserfs_transaction_handle 
*reiserfs_persistent_transaction(struct
*,
int count);
 int reiserfs_end_persistent_transaction(struct reiserfs_transaction_handle *);
+void reiserfs_vfs_truncate_file(struct inode *inode);
 int reiserfs_commit_page(struct inode *inode, struct page *page,
 unsigned from, unsigned to);
 void reiserfs_flush_old_commits(struct super_block *);
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 04/21] procfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/proc/base.c|7 ---
 fs/proc/generic.c |9 +
 fs/proc/proc_sysctl.c |7 ---
 3 files changed, 1 insertions(+), 22 deletions(-)

diff --git a/fs/proc/base.c b/fs/proc/base.c
index 144a967..6f009a3 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -542,13 +542,6 @@ int proc_setattr(struct dentry *dentry, struct iattr *attr)
if (error)
return error;
 
-   if ((attr->ia_valid & ATTR_SIZE) &&
-   attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
-   if (error)
-   return error;
-   }
-
setattr_copy(inode, attr);
mark_inode_dirty(inode);
return 0;
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 0d80cef..0c00b63 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -261,16 +261,9 @@ static int proc_notify_change(struct dentry *dentry, 
struct iattr *iattr)
if (error)
return error;
 
-   if ((iattr->ia_valid & ATTR_SIZE) &&
-   iattr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, iattr->ia_size);
-   if (error)
-   return error;
-   }
-
setattr_copy(inode, iattr);
mark_inode_dirty(inode);
-   
+
de->uid = inode->i_uid;
de->gid = inode->i_gid;
de->mode = inode->i_mode;
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index a781bdf..4b354c0 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -735,13 +735,6 @@ static int proc_sys_setattr(struct dentry *dentry, struct 
iattr *attr)
if (error)
return error;
 
-   if ((attr->ia_valid & ATTR_SIZE) &&
-   attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
-   if (error)
-   return error;
-   }
-
setattr_copy(inode, attr);
mark_inode_dirty(inode);
return 0;
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 05/21] omfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/omfs/file.c |   22 +++---
 1 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index 77e3cb2..e0d9b3e 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -306,6 +306,16 @@ omfs_writepages(struct address_space *mapping, struct 
writeback_control *wbc)
return mpage_writepages(mapping, wbc, omfs_get_block);
 }
 
+static void omfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   omfs_truncate(inode);
+   }
+}
+
 static int omfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -314,11 +324,8 @@ static int omfs_write_begin(struct file *file, struct 
address_space *mapping,
 
ret = block_write_begin(mapping, pos, len, flags, pagep,
omfs_get_block);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   omfs_write_failed(mapping, pos + len);
 
return ret;
 }
@@ -350,9 +357,11 @@ static int omfs_setattr(struct dentry *dentry, struct 
iattr *attr)
 
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
+   error = inode_newsize_ok(inode, attr->ia_size);
if (error)
return error;
+   truncate_setsize(inode, attr->ia_size);
+   omfs_truncate(inode);
}
 
setattr_copy(inode, attr);
@@ -362,7 +371,6 @@ static int omfs_setattr(struct dentry *dentry, struct iattr 
*attr)
 
 const struct inode_operations omfs_file_inops = {
.setattr = omfs_setattr,
-   .truncate = omfs_truncate
 };
 
 const struct address_space_operations omfs_aops = {
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 06/21] ocfs2: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/ocfs2/file.c |   18 --
 1 files changed, 0 insertions(+), 18 deletions(-)

diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 5a4ee77..03f0d08 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1218,24 +1218,6 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr 
*attr)
}
}
 
-   /*
-* This will intentionally not wind up calling truncate_setsize(),
-* since all the work for a size change has been done above.
-* Otherwise, we could get into problems with truncate as
-* ip_alloc_sem is used there to protect against i_size
-* changes.
-*
-* XXX: this means the conditional below can probably be removed.
-*/
-   if ((attr->ia_valid & ATTR_SIZE) &&
-   attr->ia_size != i_size_read(inode)) {
-   status = vmtruncate(inode, attr->ia_size);
-   if (status) {
-   mlog_errno(status);
-   goto bail_commit;
-   }
-   }
-
setattr_copy(inode, attr);
mark_inode_dirty(inode);
 
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 07/21] adfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/adfs/inode.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index e9bad50..5f95d1e 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -45,6 +45,14 @@ static int adfs_readpage(struct file *file, struct page 
*page)
return block_read_full_page(page, adfs_get_block);
 }
 
+static void adfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size)
+   truncate_pagecache(inode, to, inode->i_size);
+}
+
 static int adfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -55,11 +63,8 @@ static int adfs_write_begin(struct file *file, struct 
address_space *mapping,
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
adfs_get_block,
&ADFS_I(mapping->host)->mmu_private);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   adfs_write_failed(mapping, pos + len);
 
return ret;
 }
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 08/21] affs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/affs/file.c  |   18 --
 fs/affs/inode.c |5 -
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/fs/affs/file.c b/fs/affs/file.c
index 2f4c935..af3261b 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -39,7 +39,6 @@ const struct file_operations affs_file_operations = {
 };
 
 const struct inode_operations affs_file_inode_operations = {
-   .truncate   = affs_truncate,
.setattr= affs_notify_change,
 };
 
@@ -402,6 +401,16 @@ static int affs_readpage(struct file *file, struct page 
*page)
return block_read_full_page(page, affs_get_block);
 }
 
+static void affs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   affs_truncate(inode);
+   }
+}
+
 static int affs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -412,11 +421,8 @@ static int affs_write_begin(struct file *file, struct 
address_space *mapping,
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
affs_get_block,
&AFFS_I(mapping->host)->mmu_private);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   affs_write_failed(mapping, pos + len);
 
return ret;
 }
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index 15c4842..0e092d0 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -237,9 +237,12 @@ affs_notify_change(struct dentry *dentry, struct iattr 
*attr)
 
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
+   error = inode_newsize_ok(inode, attr->ia_size);
if (error)
return error;
+
+   truncate_setsize(inode, attr->ia_size);
+   affs_truncate(inode);
}
 
setattr_copy(inode, attr);
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 09/21] bfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/bfs/file.c |   15 ++-
 1 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/fs/bfs/file.c b/fs/bfs/file.c
index f20e8a7..ad3ea14 100644
--- a/fs/bfs/file.c
+++ b/fs/bfs/file.c
@@ -161,6 +161,14 @@ static int bfs_readpage(struct file *file, struct page 
*page)
return block_read_full_page(page, bfs_get_block);
 }
 
+static void bfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size)
+   truncate_pagecache(inode, to, inode->i_size);
+}
+
 static int bfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -169,11 +177,8 @@ static int bfs_write_begin(struct file *file, struct 
address_space *mapping,
 
ret = block_write_begin(mapping, pos, len, flags, pagep,
bfs_get_block);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   bfs_write_failed(mapping, pos + len);
 
return ret;
 }
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 10/21] hfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/hfs/inode.c |   26 ++
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 0b35903..d47f116 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -35,6 +35,16 @@ static int hfs_readpage(struct file *file, struct page *page)
return block_read_full_page(page, hfs_get_block);
 }
 
+static void hfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   hfs_file_truncate(inode);
+   }
+}
+
 static int hfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -45,11 +55,8 @@ static int hfs_write_begin(struct file *file, struct 
address_space *mapping,
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
hfs_get_block,
&HFS_I(mapping->host)->phys_size);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   hfs_write_failed(mapping, pos + len);
 
return ret;
 }
@@ -120,6 +127,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
const struct iovec *iov, loff_t offset, unsigned long nr_segs)
 {
struct file *file = iocb->ki_filp;
+   struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
ssize_t ret;
 
@@ -135,7 +143,7 @@ static ssize_t hfs_direct_IO(int rw, struct kiocb *iocb,
loff_t end = offset + iov_length(iov, nr_segs);
 
if (end > isize)
-   vmtruncate(inode, isize);
+   hfs_write_failed(mapping, end);
}
 
return ret;
@@ -617,9 +625,12 @@ int hfs_inode_setattr(struct dentry *dentry, struct iattr 
* attr)
attr->ia_size != i_size_read(inode)) {
inode_dio_wait(inode);
 
-   error = vmtruncate(inode, attr->ia_size);
+   error = inode_newsize_ok(inode, attr->ia_size);
if (error)
return error;
+
+   truncate_setsize(inode, attr->ia_size);
+   hfs_file_truncate(inode);
}
 
setattr_copy(inode, attr);
@@ -668,7 +679,6 @@ static const struct file_operations hfs_file_operations = {
 
 static const struct inode_operations hfs_file_inode_operations = {
.lookup = hfs_file_lookup,
-   .truncate   = hfs_file_truncate,
.setattr= hfs_inode_setattr,
.setxattr   = hfs_setxattr,
.getxattr   = hfs_getxattr,
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/21] hpfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/hpfs/file.c  |   18 --
 fs/hpfs/inode.c |5 -
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/fs/hpfs/file.c b/fs/hpfs/file.c
index 89d2a58..e7629f7 100644
--- a/fs/hpfs/file.c
+++ b/fs/hpfs/file.c
@@ -105,6 +105,16 @@ static int hpfs_readpage(struct file *file, struct page 
*page)
return block_read_full_page(page,hpfs_get_block);
 }
 
+static void hpfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   hpfs_truncate(inode);
+   }
+}
+
 static int hpfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -115,11 +125,8 @@ static int hpfs_write_begin(struct file *file, struct 
address_space *mapping,
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
hpfs_get_block,
&hpfs_i(mapping->host)->mmu_private);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   hpfs_write_failed(mapping, pos + len);
 
return ret;
 }
@@ -166,6 +173,5 @@ const struct file_operations hpfs_file_ops =
 
 const struct inode_operations hpfs_file_iops =
 {
-   .truncate   = hpfs_truncate,
.setattr= hpfs_setattr,
 };
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 804a9a8..5dc06c8 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -277,9 +277,12 @@ int hpfs_setattr(struct dentry *dentry, struct iattr *attr)
 
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
+   error = inode_newsize_ok(inode, attr->ia_size);
if (error)
goto out_unlock;
+
+   truncate_setsize(inode, attr->ia_size);
+   hpfs_truncate(inode);
}
 
setattr_copy(inode, attr);
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/21] jfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/jfs/file.c  |6 --
 fs/jfs/inode.c |   20 ++--
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 9d3afd1..dd7442c 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -119,9 +119,12 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
iattr->ia_size != i_size_read(inode)) {
inode_dio_wait(inode);
 
-   rc = vmtruncate(inode, iattr->ia_size);
+   rc = inode_newsize_ok(inode, iattr->ia_size);
if (rc)
return rc;
+
+   truncate_setsize(inode, iattr->ia_size);
+   jfs_truncate(inode);
}
 
setattr_copy(inode, iattr);
@@ -133,7 +136,6 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr)
 }
 
 const struct inode_operations jfs_file_inode_operations = {
-   .truncate   = jfs_truncate,
.setxattr   = jfs_setxattr,
.getxattr   = jfs_getxattr,
.listxattr  = jfs_listxattr,
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c
index 4692bf3..b7dc47b 100644
--- a/fs/jfs/inode.c
+++ b/fs/jfs/inode.c
@@ -300,6 +300,16 @@ static int jfs_readpages(struct file *file, struct 
address_space *mapping,
return mpage_readpages(mapping, pages, nr_pages, jfs_get_block);
 }
 
+static void jfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   jfs_truncate(inode);
+   }
+}
+
 static int jfs_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -308,11 +318,8 @@ static int jfs_write_begin(struct file *file, struct 
address_space *mapping,
 
ret = nobh_write_begin(mapping, pos, len, flags, pagep, fsdata,
jfs_get_block);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   jfs_write_failed(mapping, pos + len);
 
return ret;
 }
@@ -326,6 +333,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
const struct iovec *iov, loff_t offset, unsigned long nr_segs)
 {
struct file *file = iocb->ki_filp;
+   struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_mapping->host;
ssize_t ret;
 
@@ -341,7 +349,7 @@ static ssize_t jfs_direct_IO(int rw, struct kiocb *iocb,
loff_t end = offset + iov_length(iov, nr_segs);
 
if (end > isize)
-   vmtruncate(inode, isize);
+   jfs_write_failed(mapping, end);
}
 
return ret;
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/21] hfsplus: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/hfsplus/inode.c |   27 ---
 1 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 2172aa5..799b336 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -28,6 +28,16 @@ static int hfsplus_writepage(struct page *page, struct 
writeback_control *wbc)
return block_write_full_page(page, hfsplus_get_block, wbc);
 }
 
+static void hfsplus_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   hfsplus_file_truncate(inode);
+   }
+}
+
 static int hfsplus_write_begin(struct file *file, struct address_space 
*mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -38,11 +48,8 @@ static int hfsplus_write_begin(struct file *file, struct 
address_space *mapping,
ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
hfsplus_get_block,
&HFSPLUS_I(mapping->host)->phys_size);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   hfsplus_write_failed(mapping, pos + len);
 
return ret;
 }
@@ -116,6 +123,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
const struct iovec *iov, loff_t offset, unsigned long nr_segs)
 {
struct file *file = iocb->ki_filp;
+   struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_path.dentry->d_inode->i_mapping->host;
ssize_t ret;
 
@@ -131,7 +139,7 @@ static ssize_t hfsplus_direct_IO(int rw, struct kiocb *iocb,
loff_t end = offset + iov_length(iov, nr_segs);
 
if (end > isize)
-   vmtruncate(inode, isize);
+   hfsplus_write_failed(mapping, end);
}
 
return ret;
@@ -300,10 +308,8 @@ static int hfsplus_setattr(struct dentry *dentry, struct 
iattr *attr)
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
inode_dio_wait(inode);
-
-   error = vmtruncate(inode, attr->ia_size);
-   if (error)
-   return error;
+   truncate_setsize(inode, attr->ia_size);
+   hfsplus_file_truncate(inode);
}
 
setattr_copy(inode, attr);
@@ -358,7 +364,6 @@ int hfsplus_file_fsync(struct file *file, loff_t start, 
loff_t end,
 
 static const struct inode_operations hfsplus_file_inode_operations = {
.lookup = hfsplus_file_lookup,
-   .truncate   = hfsplus_file_truncate,
.setattr= hfsplus_setattr,
.setxattr   = hfsplus_setxattr,
.getxattr   = hfsplus_getxattr,
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/21] logfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/logfs/readwrite.c |   10 --
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/fs/logfs/readwrite.c b/fs/logfs/readwrite.c
index e1a3b6b..9a59cba 100644
--- a/fs/logfs/readwrite.c
+++ b/fs/logfs/readwrite.c
@@ -1887,9 +1887,15 @@ int logfs_truncate(struct inode *inode, u64 target)
logfs_put_wblocks(sb, NULL, 1);
}
 
-   if (!err)
-   err = vmtruncate(inode, target);
+   if (!err) {
+   err = inode_newsize_ok(inode, target);
+   if (err)
+   goto out;
+
+   truncate_setsize(inode, target);
+   }
 
+ out:
/* I don't trust error recovery yet. */
WARN_ON(err);
return err;
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 15/21] minix: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/minix/file.c  |6 --
 fs/minix/inode.c |   17 -
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/fs/minix/file.c b/fs/minix/file.c
index 4493ce6..adc6f54 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -34,9 +34,12 @@ static int minix_setattr(struct dentry *dentry, struct iattr 
*attr)
 
if ((attr->ia_valid & ATTR_SIZE) &&
attr->ia_size != i_size_read(inode)) {
-   error = vmtruncate(inode, attr->ia_size);
+   error = inode_newsize_ok(inode, attr->ia_size);
if (error)
return error;
+
+   truncate_setsize(inode, attr->ia_size);
+   minix_truncate(inode);
}
 
setattr_copy(inode, attr);
@@ -45,7 +48,6 @@ static int minix_setattr(struct dentry *dentry, struct iattr 
*attr)
 }
 
 const struct inode_operations minix_file_inode_operations = {
-   .truncate   = minix_truncate,
.setattr= minix_setattr,
.getattr= minix_getattr,
 };
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index 4fc5f8a..99541cc 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -395,6 +395,16 @@ int minix_prepare_chunk(struct page *page, loff_t pos, 
unsigned len)
return __block_write_begin(page, pos, len, minix_get_block);
 }
 
+static void minix_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   minix_truncate(inode);
+   }
+}
+
 static int minix_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
struct page **pagep, void **fsdata)
@@ -403,11 +413,8 @@ static int minix_write_begin(struct file *file, struct 
address_space *mapping,
 
ret = block_write_begin(mapping, pos, len, flags, pagep,
minix_get_block);
-   if (unlikely(ret)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-   }
+   if (unlikely(ret))
+   minix_write_failed(mapping, pos + len);
 
return ret;
 }
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/21] ncpfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/ncpfs/inode.c |4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/fs/ncpfs/inode.c b/fs/ncpfs/inode.c
index d7e9fe7..1acdad7 100644
--- a/fs/ncpfs/inode.c
+++ b/fs/ncpfs/inode.c
@@ -976,9 +976,7 @@ int ncp_notify_change(struct dentry *dentry, struct iattr 
*attr)
goto out;
 
if (attr->ia_size != i_size_read(inode)) {
-   result = vmtruncate(inode, attr->ia_size);
-   if (result)
-   goto out;
+   truncate_setsize(inode, attr->ia_size);
mark_inode_dirty(inode);
}
}
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 17/21] nilfs2: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/nilfs2/file.c |1 -
 fs/nilfs2/inode.c|   24 +++-
 fs/nilfs2/nilfs.h|1 +
 fs/nilfs2/recovery.c |3 ++-
 4 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c
index 16f35f7..6194688 100644
--- a/fs/nilfs2/file.c
+++ b/fs/nilfs2/file.c
@@ -167,7 +167,6 @@ const struct file_operations nilfs_file_operations = {
 };
 
 const struct inode_operations nilfs_file_inode_operations = {
-   .truncate   = nilfs_truncate,
.setattr= nilfs_setattr,
.permission = nilfs_permission,
.fiemap = nilfs_fiemap,
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 4d31d2c..6b49f14 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -213,6 +213,16 @@ static int nilfs_set_page_dirty(struct page *page)
return ret;
 }
 
+void nilfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   nilfs_truncate(inode);
+   }
+}
+
 static int nilfs_write_begin(struct file *file, struct address_space *mapping,
 loff_t pos, unsigned len, unsigned flags,
 struct page **pagep, void **fsdata)
@@ -227,10 +237,7 @@ static int nilfs_write_begin(struct file *file, struct 
address_space *mapping,
err = block_write_begin(mapping, pos, len, flags, pagep,
nilfs_get_block);
if (unlikely(err)) {
-   loff_t isize = mapping->host->i_size;
-   if (pos + len > isize)
-   vmtruncate(mapping->host, isize);
-
+   nilfs_write_failed(mapping, pos + len);
nilfs_transaction_abort(inode->i_sb);
}
return err;
@@ -259,6 +266,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, const struct 
iovec *iov,
loff_t offset, unsigned long nr_segs)
 {
struct file *file = iocb->ki_filp;
+   struct address_space *mapping = file->f_mapping;
struct inode *inode = file->f_mapping->host;
ssize_t size;
 
@@ -278,7 +286,7 @@ nilfs_direct_IO(int rw, struct kiocb *iocb, const struct 
iovec *iov,
loff_t end = offset + iov_length(iov, nr_segs);
 
if (end > isize)
-   vmtruncate(inode, isize);
+   nilfs_write_failed(mapping, end);
}
 
return size;
@@ -786,10 +794,8 @@ int nilfs_setattr(struct dentry *dentry, struct iattr 
*iattr)
if ((iattr->ia_valid & ATTR_SIZE) &&
iattr->ia_size != i_size_read(inode)) {
inode_dio_wait(inode);
-
-   err = vmtruncate(inode, iattr->ia_size);
-   if (unlikely(err))
-   goto out_err;
+   truncate_setsize(inode, iattr->ia_size);
+   nilfs_truncate(inode);
}
 
setattr_copy(inode, iattr);
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 74cece8..9bc72de 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -277,6 +277,7 @@ extern void nilfs_update_inode(struct inode *, struct 
buffer_head *);
 extern void nilfs_truncate(struct inode *);
 extern void nilfs_evict_inode(struct inode *);
 extern int nilfs_setattr(struct dentry *, struct iattr *);
+extern void nilfs_write_failed(struct address_space *mapping, loff_t to);
 int nilfs_permission(struct inode *inode, int mask);
 int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh);
 extern int nilfs_inode_dirty(struct inode *);
diff --git a/fs/nilfs2/recovery.c b/fs/nilfs2/recovery.c
index f1626f5..ff00a0b 100644
--- a/fs/nilfs2/recovery.c
+++ b/fs/nilfs2/recovery.c
@@ -527,7 +527,8 @@ static int nilfs_recover_dsync_blocks(struct the_nilfs 
*nilfs,
if (unlikely(err)) {
loff_t isize = inode->i_size;
if (pos + blocksize > isize)
-   vmtruncate(inode, isize);
+   nilfs_write_failed(inode->i_mapping,
+   pos + blocksize);
goto failed_inode;
}
 
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 18/21] ntfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/ntfs/file.c  |   16 +---
 fs/ntfs/inode.c |8 ++--
 fs/ntfs/inode.h |4 
 3 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 1ecf464..5b2d4f0 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -1762,6 +1762,16 @@ err_out:
return err;
 }
 
+static void ntfs_write_failed(struct address_space *mapping, loff_t to)
+{
+   struct inode *inode = mapping->host;
+
+   if (to > inode->i_size) {
+   truncate_pagecache(inode, to, inode->i_size);
+   ntfs_truncate_vfs(inode);
+   }
+}
+
 /**
  * ntfs_file_buffered_write -
  *
@@ -2022,8 +2032,9 @@ static ssize_t ntfs_file_buffered_write(struct kiocb 
*iocb,
 * allocated space, which is not a disaster.
 */
i_size = i_size_read(vi);
-   if (pos + bytes > i_size)
-   vmtruncate(vi, i_size);
+   if (pos + bytes > i_size) {
+   ntfs_write_failed(mapping, pos + bytes);
+   }
break;
}
}
@@ -2227,7 +2238,6 @@ const struct file_operations ntfs_file_ops = {
 
 const struct inode_operations ntfs_file_inode_ops = {
 #ifdef NTFS_RW
-   .truncate   = ntfs_truncate_vfs,
.setattr= ntfs_setattr,
 #endif /* NTFS_RW */
 };
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 1d27331..d3e118c 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -2866,9 +2866,11 @@ conv_err_out:
  *
  * See ntfs_truncate() description above for details.
  */
+#ifdef NTFS_RW
 void ntfs_truncate_vfs(struct inode *vi) {
ntfs_truncate(vi);
 }
+#endif
 
 /**
  * ntfs_setattr - called from notify_change() when an attribute is being 
changed
@@ -2914,8 +2916,10 @@ int ntfs_setattr(struct dentry *dentry, struct iattr 
*attr)
NInoCompressed(ni) ?
"compressed" : "encrypted");
err = -EOPNOTSUPP;
-   } else
-   err = vmtruncate(vi, attr->ia_size);
+   } else {
+   truncate_setsize(vi, attr->ia_size);
+   ntfs_truncate_vfs(vi);
+   }
if (err || ia_valid == ATTR_SIZE)
goto out;
} else {
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index db29695..76b6cfb 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -316,6 +316,10 @@ static inline void ntfs_commit_inode(struct inode *vi)
return;
 }
 
+#else
+
+static inline void ntfs_truncate_vfs(struct inode *vi) {}
+
 #endif /* NTFS_RW */
 
 #endif /* _LINUX_NTFS_INODE_H */
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 19/21] vfs: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 fs/libfs.c |2 --
 include/linux/fs.h |1 -
 2 files changed, 0 insertions(+), 3 deletions(-)

diff --git a/fs/libfs.c b/fs/libfs.c
index 7cc37ca..c8fe267 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -369,8 +369,6 @@ int simple_setattr(struct dentry *dentry, struct iattr 
*iattr)
struct inode *inode = dentry->d_inode;
int error;
 
-   WARN_ON_ONCE(inode->i_op->truncate);
-
error = inode_change_ok(inode, iattr);
if (error)
return error;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b33cfc9..131a101 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1565,7 +1565,6 @@ struct inode_operations {
int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
int (*rename) (struct inode *, struct dentry *,
struct inode *, struct dentry *);
-   void (*truncate) (struct inode *);
int (*setattr) (struct dentry *, struct iattr *);
int (*getattr) (struct vfsmount *mnt, struct dentry *, struct kstat *);
int (*setxattr) (struct dentry *, const char *,const void *,size_t,int);
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 20/21] mm: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 include/linux/mm.h |1 -
 mm/truncate.c  |   23 ---
 2 files changed, 0 insertions(+), 24 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index fa06804..95f70bb 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -977,7 +977,6 @@ static inline void unmap_shared_mapping_range(struct 
address_space *mapping,
 
 extern void truncate_pagecache(struct inode *inode, loff_t old, loff_t new);
 extern void truncate_setsize(struct inode *inode, loff_t newsize);
-extern int vmtruncate(struct inode *inode, loff_t offset);
 void truncate_pagecache_range(struct inode *inode, loff_t offset, loff_t end);
 int truncate_inode_page(struct address_space *mapping, struct page *page);
 int generic_error_remove_page(struct address_space *mapping, struct page 
*page);
diff --git a/mm/truncate.c b/mm/truncate.c
index d51ce92..c75b736 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -577,29 +577,6 @@ void truncate_setsize(struct inode *inode, loff_t newsize)
 EXPORT_SYMBOL(truncate_setsize);
 
 /**
- * vmtruncate - unmap mappings "freed" by truncate() syscall
- * @inode: inode of the file used
- * @newsize: file offset to start truncating
- *
- * This function is deprecated and truncate_setsize or truncate_pagecache
- * should be used instead, together with filesystem specific block truncation.
- */
-int vmtruncate(struct inode *inode, loff_t newsize)
-{
-   int error;
-
-   error = inode_newsize_ok(inode, newsize);
-   if (error)
-   return error;
-
-   truncate_setsize(inode, newsize);
-   if (inode->i_op->truncate)
-   inode->i_op->truncate(inode);
-   return 0;
-}
-EXPORT_SYMBOL(vmtruncate);
-
-/**
  * truncate_pagecache_range - unmap and remove pagecache that is hole-punched
  * @inode: inode
  * @lstart: offset of beginning of hole
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 21/21] documentation: drop vmtruncate

2012-11-03 Thread Marco Stornelli
Removed vmtruncate

Signed-off-by: Marco Stornelli 
---
 Documentation/filesystems/Locking |6 --
 Documentation/filesystems/porting |2 +-
 Documentation/filesystems/vfs.txt |   11 ---
 3 files changed, 1 insertions(+), 18 deletions(-)

diff --git a/Documentation/filesystems/Locking 
b/Documentation/filesystems/Locking
index e540a24..f48e0c6 100644
--- a/Documentation/filesystems/Locking
+++ b/Documentation/filesystems/Locking
@@ -80,7 +80,6 @@ rename:   yes (all)   (see below)
 readlink:  no
 follow_link:   no
 put_link:  no
-truncate:  yes (see below)
 setattr:   yes
 permission:no (may not block if called in rcu-walk mode)
 get_acl:   no
@@ -96,11 +95,6 @@ atomic_open: yes
Additionally, ->rmdir(), ->unlink() and ->rename() have ->i_mutex on
 victim.
cross-directory ->rename() has (per-superblock) ->s_vfs_rename_sem.
-   ->truncate() is never called directly - it's a callback, not a
-method. It's called by vmtruncate() - deprecated library function used by
-->setattr(). Locking information above applies to that call (i.e. is
-inherited from ->setattr() - vmtruncate() is used when ATTR_SIZE had been
-passed).
 
 See Documentation/filesystems/directory-locking for more detailed discussion
 of the locking scheme for directory operations.
diff --git a/Documentation/filesystems/porting 
b/Documentation/filesystems/porting
index 0742fee..0472c31 100644
--- a/Documentation/filesystems/porting
+++ b/Documentation/filesystems/porting
@@ -281,7 +281,7 @@ ext2_write_failed and callers for an example.
 
 [mandatory]
 
-   ->truncate is going away.  The whole truncate sequence needs to be
+   ->truncate is gone.  The whole truncate sequence needs to be
 implemented in ->setattr, which is now mandatory for filesystems
 implementing on-disk size changes.  Start with a copy of the old inode_setattr
 and vmtruncate, and the reorder the vmtruncate + foofs_vmtruncate sequence to
diff --git a/Documentation/filesystems/vfs.txt 
b/Documentation/filesystems/vfs.txt
index 2ee133e..e386909 100644
--- a/Documentation/filesystems/vfs.txt
+++ b/Documentation/filesystems/vfs.txt
@@ -350,7 +350,6 @@ struct inode_operations {
int (*readlink) (struct dentry *, char __user *,int);
 void * (*follow_link) (struct dentry *, struct nameidata *);
 void (*put_link) (struct dentry *, struct nameidata *, void *);
-   void (*truncate) (struct inode *);
int (*permission) (struct inode *, int);
int (*get_acl)(struct inode *, int);
int (*setattr) (struct dentry *, struct iattr *);
@@ -431,16 +430,6 @@ otherwise noted.
started might not be in the page cache at the end of the
walk).
 
-  truncate: Deprecated. This will not be called if ->setsize is defined.
-   Called by the VFS to change the size of a file.  The
-   i_size field of the inode is set to the desired size by the
-   VFS before this method is called.  This method is called by
-   the truncate(2) system call and related functionality.
-
-   Note: ->truncate and vmtruncate are deprecated. Do not add new
-   instances/calls of these. Filesystems should be converted to do their
-   truncate sequence via ->setattr().
-
   permission: called by the VFS to check for access rights on a POSIX-like
filesystem.
 
-- 
1.7.3.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] hid-apple.c: Set APPLE_ISO_KEYBOARD at USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO

2012-11-03 Thread Johannes Thumshirn
Set APPLE_ISO_KEYBOARD flag on USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO so we get
the ISO translation on German keyboards for the MacBook4,1 as well.

Signed-off-by: Johannes Thumshirn 
---
 drivers/hid/hid-apple.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/hid-apple.c b/drivers/hid/hid-apple.c
index 06ebdbb..5df5e20 100644
--- a/drivers/hid/hid-apple.c
+++ b/drivers/hid/hid-apple.c
@@ -439,7 +439,8 @@ static const struct hid_device_id apple_devices[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 
USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI),
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 
USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO),
-   .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN },
+   .driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
+   APPLE_ISO_KEYBOARD },
{ HID_USB_DEVICE(USB_VENDOR_ID_APPLE, 
USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS),
.driver_data = APPLE_NUMLOCK_EMULATION | APPLE_HAS_FN |
APPLE_RDESC_JIS },
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/2] firmware loader: introduce module parameter to customize(v4) fw search path

2012-11-03 Thread Ming Lei
This patch introduces one module parameter of 'path' in firmware_class
to support customizing firmware image search path, so that people can
use its own firmware path if the default built-in paths can't meet their
demand[1], and the typical usage is passing the below from kernel command
parameter when 'firmware_class' is built in kernel:

firmware_class.path=$CUSTOMIZED_PATH

[1], https://lkml.org/lkml/2012/10/11/337

Cc: Linus Torvalds 
Signed-off-by: Ming Lei 
---
v4:
- fix one comment and rebase on the latest next tree
v3:
- fix one mistake on checking unset firmware path
v2:
- take a cleaner approach suggested by Linus
- mark the path array as const because it needn't be changed
- fix one error in Document about the module name
v1:
- remove kernel boot parameter and only support the feature by
module parameter as suggested by Greg
---
 Documentation/firmware_class/README |5 +
 drivers/base/firmware_class.c   |   17 -
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/firmware_class/README 
b/Documentation/firmware_class/README
index 815b711..e9fce78 100644
--- a/Documentation/firmware_class/README
+++ b/Documentation/firmware_class/README
@@ -22,12 +22,17 @@
- calls request_firmware(&fw_entry, $FIRMWARE, device)
- kernel searchs the fimware image with name $FIRMWARE directly
in the below search path of root filesystem:
+   User customized search path by module parameter 'path'[1]
"/lib/firmware/updates/" UTS_RELEASE,
"/lib/firmware/updates",
"/lib/firmware/" UTS_RELEASE,
"/lib/firmware"
- If found, goto 7), else goto 2)
 
+   [1], the 'path' is a string parameter which length should be less
+   than 256, user should pass 'firmware_class.path=$CUSTOMIZED_PATH'
+   if firmware_class is built in kernel(the general situation)
+
  2), userspace:
- /sys/class/firmware/xxx/{loading,data} appear.
- hotplug gets called with a firmware identifier in $FIRMWARE
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 620b876..2067514 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -267,13 +267,23 @@ static void fw_free_buf(struct firmware_buf *buf)
 }
 
 /* direct firmware loading support */
-static const char *fw_path[] = {
+static char fw_path_para[256];
+static const char * const fw_path[] = {
+   fw_path_para,
"/lib/firmware/updates/" UTS_RELEASE,
"/lib/firmware/updates",
"/lib/firmware/" UTS_RELEASE,
"/lib/firmware"
 };
 
+/*
+ * Typical usage is that passing 'firmware_class.path=$CUSTOMIZED_PATH'
+ * from kernel command line because firmware_class is generally built in
+ * kernel instead of module.
+ */
+module_param_string(path, fw_path_para, sizeof(fw_path_para), 0644);
+MODULE_PARM_DESC(path, "customized firmware image search path with a higher 
priority than default path");
+
 /* Don't inline this: 'struct kstat' is biggish */
 static noinline_for_stack long fw_file_size(struct file *file)
 {
@@ -315,6 +325,11 @@ static bool fw_get_filesystem_firmware(struct firmware_buf 
*buf)
 
for (i = 0; i < ARRAY_SIZE(fw_path); i++) {
struct file *file;
+
+   /* skip the unset customized path */
+   if (!fw_path[i][0])
+   continue;
+
snprintf(path, PATH_MAX, "%s/%s", fw_path[i], buf->fw_id);
 
file = filp_open(path, O_RDONLY, 0);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/2] firmware loader: document firmware cache mechanism

2012-11-03 Thread Ming Lei
From: Ming Lei 

This patch documents the firmware cache mechanism so that
users of request_firmware() know that it can be called
safely inside device's suspend and resume callback, and
the device's firmware needn't be cached any more by individual
driver itself to deal with firmware loss during system resume.

Signed-off-by: Ming Lei 
---
 Documentation/firmware_class/README |7 +++
 drivers/base/firmware_class.c   |3 +++
 2 files changed, 10 insertions(+)

diff --git a/Documentation/firmware_class/README 
b/Documentation/firmware_class/README
index e9fce78..43fada9 100644
--- a/Documentation/firmware_class/README
+++ b/Documentation/firmware_class/README
@@ -119,3 +119,10 @@
on the setup, so I think that the choice on what firmware to make
persistent should be left to userspace.
 
+ about firmware cache:
+ 
+ After firmware cache mechanism is introduced during system sleep,
+ request_firmware can be called safely inside device's suspend and
+ resume callback, and callers need't cache the firmware by
+ themselves any more for dealing with firmware loss during system
+ resume.
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 2067514..15f2822 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -978,6 +978,9 @@ err_put_dev:
  *  firmware image for this or any other device.
  *
  * Caller must hold the reference count of @device.
+ *
+ * The function can be called safely inside device's suspend and
+ * resume callback.
  **/
 int
 request_firmware(const struct firmware **firmware_p, const char *name,
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] atp: remove set_rx_mode_8012()

2012-11-03 Thread Paul Bolle
Building atp.o triggers this GCC warning:
drivers/net/ethernet/realtek/atp.c: In function ‘set_rx_mode’:
drivers/net/ethernet/realtek/atp.c:871:26: warning: ‘mc_filter[0]’ may be 
used uninitialized in this function [-Wuninitialized]

GCC is correct. In promiscuous mode 'mc_filter' will be used
uninitialized in set_rx_mode_8012(), which is apparently inlined into
set_rx_mode().

But it turns out set_rx_mode_8012() will never be called, since
net_local.chip_type will always be RTL8002. So we can just remove
set_rx_mode_8012() and do some related cleanups.

Signed-off-by: Paul Bolle 
---
Note: compile test only.

 drivers/net/ethernet/realtek/atp.c | 58 ++
 drivers/net/ethernet/realtek/atp.h |  2 --
 2 files changed, 2 insertions(+), 58 deletions(-)

diff --git a/drivers/net/ethernet/realtek/atp.c 
b/drivers/net/ethernet/realtek/atp.c
index e02f04d..9f2d416 100644
--- a/drivers/net/ethernet/realtek/atp.c
+++ b/drivers/net/ethernet/realtek/atp.c
@@ -175,8 +175,7 @@ struct net_local {
 unsigned int tx_unit_busy:1;
 unsigned char re_tx,   /* Number of packet retransmissions. */
addr_mode,  /* Current Rx filter e.g. promiscuous, 
etc. */
-   pac_cnt_in_tx_buf,
-   chip_type;
+   pac_cnt_in_tx_buf;
 };
 
 /* This code, written by w...@super.org, resets the adapter every
@@ -339,7 +338,6 @@ static int __init atp_probe1(long ioaddr)
write_reg_high(ioaddr, CMR1, CMR1h_RESET | CMR1h_MUX);
 
lp = netdev_priv(dev);
-   lp->chip_type = RTL8002;
lp->addr_mode = CMR2h_Normal;
spin_lock_init(&lp->lock);
 
@@ -852,7 +850,7 @@ net_close(struct net_device *dev)
  * Set or clear the multicast filter for this adapter.
  */
 
-static void set_rx_mode_8002(struct net_device *dev)
+static void set_rx_mode(struct net_device *dev)
 {
struct net_local *lp = netdev_priv(dev);
long ioaddr = dev->base_addr;
@@ -864,58 +862,6 @@ static void set_rx_mode_8002(struct net_device *dev)
write_reg_high(ioaddr, CMR2, lp->addr_mode);
 }
 
-static void set_rx_mode_8012(struct net_device *dev)
-{
-   struct net_local *lp = netdev_priv(dev);
-   long ioaddr = dev->base_addr;
-   unsigned char new_mode, mc_filter[8]; /* Multicast hash filter */
-   int i;
-
-   if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
-   new_mode = CMR2h_PROMISC;
-   } else if ((netdev_mc_count(dev) > 1000) ||
-  (dev->flags & IFF_ALLMULTI)) {
-   /* Too many to filter perfectly -- accept all multicasts. */
-   memset(mc_filter, 0xff, sizeof(mc_filter));
-   new_mode = CMR2h_Normal;
-   } else {
-   struct netdev_hw_addr *ha;
-
-   memset(mc_filter, 0, sizeof(mc_filter));
-   netdev_for_each_mc_addr(ha, dev) {
-   int filterbit = ether_crc_le(ETH_ALEN, ha->addr) & 0x3f;
-   mc_filter[filterbit >> 5] |= 1 << (filterbit & 31);
-   }
-   new_mode = CMR2h_Normal;
-   }
-   lp->addr_mode = new_mode;
-write_reg(ioaddr, CMR2, CMR2_IRQOUT | 0x04); /* Switch to page 1. */
-for (i = 0; i < 8; i++)
-   write_reg_byte(ioaddr, i, mc_filter[i]);
-   if (net_debug > 2 || 1) {
-   lp->addr_mode = 1;
-   printk(KERN_DEBUG "%s: Mode %d, setting multicast filter to",
-  dev->name, lp->addr_mode);
-   for (i = 0; i < 8; i++)
-   printk(" %2.2x", mc_filter[i]);
-   printk(".\n");
-   }
-
-   write_reg_high(ioaddr, CMR2, lp->addr_mode);
-write_reg(ioaddr, CMR2, CMR2_IRQOUT); /* Switch back to page 0 */
-}
-
-static void set_rx_mode(struct net_device *dev)
-{
-   struct net_local *lp = netdev_priv(dev);
-
-   if (lp->chip_type == RTL8002)
-   return set_rx_mode_8002(dev);
-   else
-   return set_rx_mode_8012(dev);
-}
-
-
 static int __init atp_init_module(void) {
if (debug)  /* Emit version even if 
no cards detected. */
printk(KERN_INFO "%s", version);
diff --git a/drivers/net/ethernet/realtek/atp.h 
b/drivers/net/ethernet/realtek/atp.h
index 0edc642..040b137 100644
--- a/drivers/net/ethernet/realtek/atp.h
+++ b/drivers/net/ethernet/realtek/atp.h
@@ -16,8 +16,6 @@ struct rx_header {
 #define PAR_STATUS 1
 #define PAR_CONTROL 2
 
-enum chip_type { RTL8002, RTL8012 };
-
 #define Ctrl_LNibRead  0x08/* LP_PSELECP */
 #define Ctrl_HNibRead  0
 #define Ctrl_LNibWrite 0x08/* LP_PSELECP */
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [REGRESSION] i915: failure to interoperate with HP ZR30w using an X230

2012-11-03 Thread Daniel Vetter
On Fri, Nov 02, 2012 at 08:58:31PM -0400, Theodore Ts'o wrote:
> Ping?
> 
> On Tue, Oct 30, 2012 at 04:32:21PM -0400, Theodore Ts'o wrote:
> > On Tue, Oct 30, 2012 at 01:57:27PM +0200, Jani Nikula wrote:
> > > > [1] drm-intel-next-queued branch at 
> > > > git://people.freedesktop.org/~danvet/drm-intel
> > > 
> > > Hmm, actually not. Either drm-intel-fixes branch, or Linus' master.
> > 
> > Confirmed, the drm-intel-fixes branch from Daniel's tree
> > (3.7.0-rc2-00031-g1623392) works fine for me.
> > 
> > Do you know which commit(s) are likely to have fixed the problem, so we
> > can cherry pick the appropriate fix(es) to the 3.6.x tree?

Well, we know for sure that fdi link training is broken - it doesn't match
at all what the spec says we should do. I've been working on this lately,
since in quite a few circumstances the link train fails without the
relevent bits indicating so. While testing I've also noticed that this
entire thing is highly timing dependent, e.g. denpending upon which
desktop is running and which tool I use to change the configuration it
fails or succeeds.

So I have no suggestions for what could help your system and what should
get backported, since the current code is still broken.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: AMD A10: MCE Instruction Cache Error

2012-11-03 Thread Alexander Holler

Am 03.11.2012 05:49, schrieb Borislav Petkov:

On Fri, Nov 02, 2012 at 02:53:45PM +0100, Alexander Holler wrote:

Am 02.11.2012 11:50, schrieb Alexander Holler:

Hello,

I've just got the following on an AMD A10 5800K:

--
[ 8395.999581] [Hardware Error]: CPU:0
MC1_STATUS[-|CE|MiscV|-|AddrV|-|-]: 0x8c210151
[ 8395.999586] [Hardware Error]:MC1_ADDR: 0xa00e1203
[ 8395.999588] [Hardware Error]: Instruction Cache Error: Parity error
during data load from IC.
[ 8395.999590] [Hardware Error]: cache level: L1, tx: INSN, mem-tx: IRD
--

Kernel is 3.6.5, MB is an Asus F2A85-M with BIOS 5103 (the latest).


...

So now I have two question:

- First, if the error is something I should ask AMD about,


Not really, it is a single bit flip which got corrected, simply watch
out if you get more of those.


- Second, if the kernel could mention that it is an recoverable
error. And if so and if such errors aren't something to get panic
(e.g. it isn't unusual to receive such), if the kernel could output
that message with another priority.


As I said above, it got corrected. If it were critical, it would've
either panicked or you wouldnt've seen it at all (probably only after
reboot).


Hmm, exactly that just happened twice in a row. Unfortunately the screen 
was already disabled (screen saving mode), so I couldn't see any 
message, if there was any. Just a dead box (not overclocked, I don't do 
such, I even had enabled the power saving mode in the BIOS, which seems 
to mean max. 3800 MHz). I think I should start getting nervous. :(


What I meant with another priority is using something else than 
pr_emerg(), because pr_emerge() causes the message to become displayed 
on every console, at least on my F17 with default settings.


Of course, I'm happy it was displayed using pr_emerg() so I haven't 
missed it. Now I know that even if ECC isn't available for users which 
don't want or need power hungry and loud servers, at least some parity 
is used to verify the operations with the internal memory (cache).


But on the other way, if that message isn't really critical, something 
else than pr_emerge() should be used.


Thanks for the answer.

Regards,

Alexander

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/16] use WARN

2012-11-03 Thread Julia Lawall
These patches use WARN, which combines printk and WARN_ON(1), or WARN_ONCE,
which combines printk and WARN_ON_ONCE(1).  This does not appear to affect
the behavior, but makes the code a little more concise.

The semantic patch that makes this transformation is as follows
(http://coccinelle.lip6.fr/).  In particular, it only transforms the case
where the WARN_ON or WARN_ON_ONCE is preceded by a single printk.

// 
@bad1@
position p;
@@

printk(...);
printk@p(...);
WARN_ON(1);

@ok1@
expression list es;
position p != bad1.p;
@@

-printk@p(
+WARN(1,
  es);
-WARN_ON(1);

@@
expression list ok1.es;
@@

if (...)
- {
  WARN(1,es);
- }

@bad2@
position p;
@@

printk(...);
printk@p(...);
WARN_ON_ONCE(1);

@ok2@
expression list es;
position p != bad2.p;
@@

-printk@p(
+WARN_ONCE(1,
  es);
-WARN_ON_ONCE(1);

@@
expression list ok2.es;
@@

if (...)
- {
  WARN_ONCE(1,es);
- }
// 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/16] drivers/md/raid5.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/md/raid5.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 320df0c..8c3b9bb 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -373,13 +373,11 @@ static void init_stripe(struct stripe_head *sh, sector_t 
sector, int previous)
struct r5dev *dev = &sh->dev[i];
 
if (dev->toread || dev->read || dev->towrite || dev->written ||
-   test_bit(R5_LOCKED, &dev->flags)) {
-   printk(KERN_ERR "sector=%llx i=%d %p %p %p %p %d\n",
+   test_bit(R5_LOCKED, &dev->flags))
+   WARN(1, KERN_ERR "sector=%llx i=%d %p %p %p %p %d\n",
   (unsigned long long)sh->sector, i, dev->toread,
   dev->read, dev->towrite, dev->written,
   test_bit(R5_LOCKED, &dev->flags));
-   WARN_ON(1);
-   }
dev->flags = 0;
raid5_build_block(sh, i, previous);
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/16] drivers/scsi: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/scsi/initio.c   |3 +--
 drivers/scsi/scsi_lib.c |3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index dd741bc..1572860 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2774,8 +2774,7 @@ static void i91uSCBPost(u8 * host_mem, u8 * cblk_mem)
host = (struct initio_host *) host_mem;
cblk = (struct scsi_ctrl_blk *) cblk_mem;
if ((cmnd = cblk->srb) == NULL) {
-   printk(KERN_ERR "i91uSCBPost: SRB pointer is empty\n");
-   WARN_ON(1);
+   WARN(1, KERN_ERR "i91uSCBPost: SRB pointer is empty\n");
initio_release_scb(host, cblk); /* Release SCB for current 
channel */
return;
}
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index da36a3a..e5fdcae 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2573,10 +2573,9 @@ void *scsi_kmap_atomic_sg(struct scatterlist *sgl, int 
sg_count,
}
 
if (unlikely(i == sg_count)) {
-   printk(KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, "
+   WARN(1, KERN_ERR "%s: Bytes in sg: %zu, requested offset %zu, "
"elements %d\n",
   __func__, sg_len, *offset, sg_count);
-   WARN_ON(1);
return NULL;
}
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



[PATCH 10/16] drivers/net/ethernet/ibm/emac/mal.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/net/ethernet/ibm/emac/mal.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/mal.c 
b/drivers/net/ethernet/ibm/emac/mal.c
index 479e43e..84c6b6c 100644
--- a/drivers/net/ethernet/ibm/emac/mal.c
+++ b/drivers/net/ethernet/ibm/emac/mal.c
@@ -738,13 +738,11 @@ static int __devexit mal_remove(struct platform_device 
*ofdev)
/* Synchronize with scheduled polling */
napi_disable(&mal->napi);
 
-   if (!list_empty(&mal->list)) {
+   if (!list_empty(&mal->list))
/* This is *very* bad */
-   printk(KERN_EMERG
+   WARN(1, KERN_EMERG
   "mal%d: commac list is not empty on remove!\n",
   mal->index);
-   WARN_ON(1);
-   }
 
dev_set_drvdata(&ofdev->dev, NULL);
 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 11/16] drivers/misc/kgdbts.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/misc/kgdbts.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
index 3aa9a96..8b367db 100644
--- a/drivers/misc/kgdbts.c
+++ b/drivers/misc/kgdbts.c
@@ -114,9 +114,8 @@
touch_nmi_watchdog();   \
} while (0)
 #define eprintk(a...) do { \
-   printk(KERN_ERR a); \
-   WARN_ON(1); \
-   } while (0)
+   WARN(1, KERN_ERR a); \
+   } while (0)
 #define MAX_CONFIG_LEN 40
 
 static struct kgdb_io kgdbts_io_ops;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 12/16] fs/logfs/gc.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 fs/logfs/gc.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/logfs/gc.c b/fs/logfs/gc.c
index d4efb06..62dee03 100644
--- a/fs/logfs/gc.c
+++ b/fs/logfs/gc.c
@@ -55,9 +55,8 @@ static u8 root_distance(struct super_block *sb, gc_level_t 
__gc_level)
/* inode file data or indirect blocks */
return super->s_ifile_levels - (gc_level - 6);
default:
-   printk(KERN_ERR"LOGFS: segment of unknown level %x found\n",
+   WARN(1, KERN_ERR "LOGFS: segment of unknown level %x found\n",
gc_level);
-   WARN_ON(1);
return super->s_ifile_levels + super->s_iblock_levels;
}
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 16/16] drivers/infiniband/hw/nes: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/infiniband/hw/nes/nes_cm.c  |6 ++
 drivers/infiniband/hw/nes/nes_mgt.c |6 ++
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/infiniband/hw/nes/nes_cm.c 
b/drivers/infiniband/hw/nes/nes_cm.c
index cfaacaf..8a15a1d 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -629,11 +629,9 @@ static void build_rdma0_msg(struct nes_cm_node *cm_node, 
struct nes_qp **nesqp_a
 
case SEND_RDMA_READ_ZERO:
default:
-   if (cm_node->send_rdma0_op != SEND_RDMA_READ_ZERO) {
-   printk(KERN_ERR "%s[%u]: Unsupported RDMA0 len 
operation=%u\n",
+   if (cm_node->send_rdma0_op != SEND_RDMA_READ_ZERO)
+   WARN(1, KERN_ERR "%s[%u]: Unsupported RDMA0 len 
operation=%u\n",
 __func__, __LINE__, cm_node->send_rdma0_op);
-   WARN_ON(1);
-   }
nes_debug(NES_DBG_CM, "Sending first rdma operation.\n");
wqe->wqe_words[NES_IWARP_SQ_WQE_MISC_IDX] =
cpu_to_le32(NES_IWARP_SQ_OP_RDMAR);
diff --git a/drivers/infiniband/hw/nes/nes_mgt.c 
b/drivers/infiniband/hw/nes/nes_mgt.c
index 3ba7be3..53bb88c 100644
--- a/drivers/infiniband/hw/nes/nes_mgt.c
+++ b/drivers/infiniband/hw/nes/nes_mgt.c
@@ -649,11 +649,9 @@ static void nes_chg_qh_handler(struct nes_device *nesdev, 
struct nes_cqp_request
nesqp = qh_chg->nesqp;
 
/* Should we handle the bad completion */
-   if (cqp_request->major_code) {
-   printk(KERN_ERR PFX "Invalid cqp_request major_code=0x%x\n",
+   if (cqp_request->major_code)
+   WARN(1, KERN_ERR PFX "Invalid cqp_request major_code=0x%x\n",
   cqp_request->major_code);
-   WARN_ON(1);
-   }
 
switch (nesqp->pau_state) {
case PAU_DEL_QH:

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 15/16] drivers/parisc/pdc_stable.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/parisc/pdc_stable.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c
index 246a92f..0f54ab6 100644
--- a/drivers/parisc/pdc_stable.c
+++ b/drivers/parisc/pdc_stable.c
@@ -212,12 +212,10 @@ pdcspath_store(struct pdcspath_entry *entry)
entry, devpath, entry->addr);
 
/* addr, devpath and count must be word aligned */
-   if (pdc_stable_write(entry->addr, devpath, sizeof(*devpath)) != PDC_OK) 
{
-   printk(KERN_ERR "%s: an error occurred when writing to PDC.\n"
+   if (pdc_stable_write(entry->addr, devpath, sizeof(*devpath)) != PDC_OK)
+   WARN(1, KERN_ERR "%s: an error occurred when writing to PDC.\n"
"It is likely that the Stable Storage data has 
been corrupted.\n"
"Please check it carefully upon next 
reboot.\n", __func__);
-   WARN_ON(1);
-   }

/* kobject is already registered */
entry->ready = 2;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/16] drivers/usb/wusbcore: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/usb/wusbcore/wa-xfer.c |3 +--
 drivers/usb/wusbcore/wusbhc.c  |3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
index 57c01ab..1b80601 100644
--- a/drivers/usb/wusbcore/wa-xfer.c
+++ b/drivers/usb/wusbcore/wa-xfer.c
@@ -1124,9 +1124,8 @@ int wa_urb_dequeue(struct wahc *wa, struct urb *urb)
switch (seg->status) {
case WA_SEG_NOTREADY:
case WA_SEG_READY:
-   printk(KERN_ERR "xfer %p#%u: dequeue bad state %u\n",
+   WARN(1, KERN_ERR "xfer %p#%u: dequeue bad state %u\n",
   xfer, cnt, seg->status);
-   WARN_ON(1);
break;
case WA_SEG_DELAYED:
seg->status = WA_SEG_ABORTED;
diff --git a/drivers/usb/wusbcore/wusbhc.c b/drivers/usb/wusbcore/wusbhc.c
index 0faca16..bb5e649 100644
--- a/drivers/usb/wusbcore/wusbhc.c
+++ b/drivers/usb/wusbcore/wusbhc.c
@@ -435,9 +435,8 @@ static void __exit wusbcore_exit(void)
char buf[256];
bitmap_scnprintf(buf, sizeof(buf), wusb_cluster_id_table,
 CLUSTER_IDS);
-   printk(KERN_ERR "BUG: WUSB Cluster IDs not released "
+   WARN(1, KERN_ERR "BUG: WUSB Cluster IDs not released "
   "on exit: %s\n", buf);
-   WARN_ON(1);
}
usb_unregister_notify(&wusb_usb_notifier);
destroy_workqueue(wusbd);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 14/16] drivers/ssb/main.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/ssb/main.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index df0f145..519688d 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -1118,8 +1118,7 @@ static u32 ssb_tmslow_reject_bitmask(struct ssb_device 
*dev)
case SSB_IDLOW_SSBREV_27: /* same here */
return SSB_TMSLOW_REJECT;   /* this is a guess */
default:
-   printk(KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
-   WARN_ON(1);
+   WARN(1, KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
}
return (SSB_TMSLOW_REJECT | SSB_TMSLOW_REJECT_23);
 }

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 13/16] fs/btrfs: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
Many of these end up with the form
if (somewhat_complex_condition) WARN(1, ...)
They could also be converted to WARN(somewhat_complex_condition, ...)
if that would be preferred.

 fs/btrfs/ctree.c   |   19 +++
 fs/btrfs/disk-io.c |6 ++
 fs/btrfs/extent-tree.c |7 +++
 fs/btrfs/extent_io.c   |9 +++--
 fs/btrfs/inode.c   |3 +--
 fs/btrfs/transaction.c |   12 
 fs/btrfs/volumes.c |3 +--
 7 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index cdfb4c4..adfa929 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1361,19 +1361,16 @@ noinline int btrfs_cow_block(struct btrfs_trans_handle 
*trans,
u64 search_start;
int ret;
 
-   if (trans->transaction != root->fs_info->running_transaction) {
-   printk(KERN_CRIT "trans %llu running %llu\n",
+   if (trans->transaction != root->fs_info->running_transaction)
+   WARN(1, KERN_CRIT "trans %llu running %llu\n",
   (unsigned long long)trans->transid,
   (unsigned long long)
   root->fs_info->running_transaction->transid);
-   WARN_ON(1);
-   }
-   if (trans->transid != root->fs_info->generation) {
-   printk(KERN_CRIT "trans %llu running %llu\n",
+
+   if (trans->transid != root->fs_info->generation)
+   WARN(1, KERN_CRIT "trans %llu running %llu\n",
   (unsigned long long)trans->transid,
   (unsigned long long)root->fs_info->generation);
-   WARN_ON(1);
-   }
 
if (!should_cow_block(trans, root, buf)) {
*cow_ret = buf;
@@ -3642,11 +3639,9 @@ static noinline int __push_leaf_left(struct 
btrfs_trans_handle *trans,
btrfs_set_header_nritems(left, old_left_nritems + push_items);
 
/* fixup right node */
-   if (push_items > right_nritems) {
-   printk(KERN_CRIT "push items %d nr %u\n", push_items,
+   if (push_items > right_nritems)
+   WARN(1, KERN_CRIT "push items %d nr %u\n", push_items,
   right_nritems);
-   WARN_ON(1);
-   }
 
if (push_items < right_nritems) {
push_space = btrfs_item_offset_nr(right, push_items - 1) -
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 22a0439..1769e7d 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -3383,14 +3383,12 @@ void btrfs_mark_buffer_dirty(struct extent_buffer *buf)
int was_dirty;
 
btrfs_assert_tree_locked(buf);
-   if (transid != root->fs_info->generation) {
-   printk(KERN_CRIT "btrfs transid mismatch buffer %llu, "
+   if (transid != root->fs_info->generation)
+   WARN(1, KERN_CRIT "btrfs transid mismatch buffer %llu, "
   "found %llu running %llu\n",
(unsigned long long)buf->start,
(unsigned long long)transid,
(unsigned long long)root->fs_info->generation);
-   WARN_ON(1);
-   }
was_dirty = set_extent_buffer_dirty(buf);
if (!was_dirty) {
spin_lock(&root->fs_info->delalloc_lock);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3d3e2c1..37353eb 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -6292,10 +6292,9 @@ use_block_rsv(struct btrfs_trans_handle *trans,
static DEFINE_RATELIMIT_STATE(_rs,
DEFAULT_RATELIMIT_INTERVAL,
/*DEFAULT_RATELIMIT_BURST*/ 2);
-   if (__ratelimit(&_rs)) {
-   printk(KERN_DEBUG "btrfs: block rsv returned %d\n", 
ret);
-   WARN_ON(1);
-   }
+   if (__ratelimit(&_rs))
+   WARN(1, KERN_DEBUG "btrfs: block rsv returned %d\n",
+ret);
ret = reserve_metadata_bytes(root, block_rsv, blocksize, 0);
if (!ret) {
return block_rsv;
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 472873a..3c062c8 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -341,12 +341,10 @@ static int insert_state(struct extent_io_tree *tree,
 {
struct rb_node *node;
 
-   if (end < start) {
-   printk(KERN_ERR "btrfs end < start %llu %llu\n",
+   if (end < start)
+   WARN(1, KERN_ERR "btrfs end < start %llu %llu\n",
   (unsigned long long)end,
   (unsigned lo

[PATCH 9/16] fs/ext4/indirect.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 fs/ext4/indirect.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
index 792e388..0cdd20f 100644
--- a/fs/ext4/indirect.c
+++ b/fs/ext4/indirect.c
@@ -354,9 +354,8 @@ static int ext4_alloc_blocks(handle_t *handle, struct inode 
*inode,
 * for the first direct block
 */
new_blocks[index] = current_block;
-   printk(KERN_INFO "%s returned more blocks than "
+   WARN(1, KERN_INFO "%s returned more blocks than "
"requested\n", __func__);
-   WARN_ON(1);
break;
}
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 8/16] drivers/infiniband/hw/cxgb3/iwch_cm.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/infiniband/hw/cxgb3/iwch_cm.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb3/iwch_cm.c 
b/drivers/infiniband/hw/cxgb3/iwch_cm.c
index aaf88ef..8baaf0d 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cm.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cm.c
@@ -128,9 +128,8 @@ static void stop_ep_timer(struct iwch_ep *ep)
 {
PDBG("%s ep %p\n", __func__, ep);
if (!timer_pending(&ep->timer)) {
-   printk(KERN_ERR "%s timer stopped when its not running!  ep %p 
state %u\n",
+   WARN(1, KERN_ERR "%s timer stopped when its not running!  ep %p 
state %u\n",
__func__, ep, ep->com.state);
-   WARN_ON(1);
return;
}
del_timer_sync(&ep->timer);
@@ -1756,9 +1755,8 @@ static void ep_timeout(unsigned long arg)
__state_set(&ep->com, ABORTING);
break;
default:
-   printk(KERN_ERR "%s unexpected state ep %p state %u\n",
+   WARN(1, KERN_ERR "%s unexpected state ep %p state %u\n",
__func__, ep, ep->com.state);
-   WARN_ON(1);
abort = 0;
}
spin_unlock_irqrestore(&ep->com.lock, flags);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 7/16] drivers/scsi/gdth.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

If (count) is also merged into WARN, for further conciseness.

A simplified version of the semantic patch that makes part of this
transformation is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/scsi/gdth.c |7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c
index 5d72274..0dbcb27 100644
--- a/drivers/scsi/gdth.c
+++ b/drivers/scsi/gdth.c
@@ -2318,11 +2318,10 @@ static void gdth_copy_internal_data(gdth_ha_str *ha, 
Scsi_Cmnd *scp,
 break;
 buffer += cpnow;
 }
-} else if (count) {
-printk("GDT-HA %d: SCSI command with no buffers but data transfer 
expected!\n",
-   ha->hanum);
-WARN_ON(1);
 }
+   else
+   WARN(count, "GDT-HA %d: SCSI command with no buffers but data 
transfer expected!\n",
+ha->hanum);
 }
 
 static int gdth_internal_cache_cmd(gdth_ha_str *ha, Scsi_Cmnd *scp)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 6/16] drivers/infiniband/hw/cxgb4/cm.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/infiniband/hw/cxgb4/cm.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
index 6cfd4d8..ed048b9 100644
--- a/drivers/infiniband/hw/cxgb4/cm.c
+++ b/drivers/infiniband/hw/cxgb4/cm.c
@@ -151,9 +151,8 @@ static void stop_ep_timer(struct c4iw_ep *ep)
 {
PDBG("%s ep %p\n", __func__, ep);
if (!timer_pending(&ep->timer)) {
-   printk(KERN_ERR "%s timer stopped when its not running! "
+   WARN(1, KERN_ERR "%s timer stopped when its not running! "
   "ep %p state %u\n", __func__, ep, ep->com.state);
-   WARN_ON(1);
return;
}
del_timer_sync(&ep->timer);
@@ -2551,9 +2550,8 @@ static void process_timeout(struct c4iw_ep *ep)
__state_set(&ep->com, ABORTING);
break;
default:
-   printk(KERN_ERR "%s unexpected state ep %p tid %u state %u\n",
+   WARN(1, KERN_ERR "%s unexpected state ep %p tid %u state %u\n",
__func__, ep, ep->hwtid, ep->com.state);
-   WARN_ON(1);
abort = 0;
}
mutex_unlock(&ep->com.mutex);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/16] fs/hfsplus/bnode.c: use WARN

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN rather than printk followed by WARN_ON(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN(1,
  es);
-WARN_ON(1);
// 

Signed-off-by: Julia Lawall 

---
 fs/hfsplus/bnode.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/hfsplus/bnode.c b/fs/hfsplus/bnode.c
index 5c125ce..7a92c2c 100644
--- a/fs/hfsplus/bnode.c
+++ b/fs/hfsplus/bnode.c
@@ -588,8 +588,7 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, 
u32 num)
node = hfs_bnode_findhash(tree, num);
spin_unlock(&tree->hash_lock);
if (node) {
-   printk(KERN_CRIT "new node %u already hashed?\n", num);
-   WARN_ON(1);
+   WARN(1, KERN_CRIT "new node %u already hashed?\n", num);
return node;
}
node = __hfs_bnode_create(tree, num);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/16] drivers/gpu/drm/drm_cache.c: use WARN_ONCE

2012-11-03 Thread Julia Lawall
From: Julia Lawall 

Use WARN_ONCE rather than printk followed by WARN_ON_ONCE(1), for conciseness.

A simplified version of the semantic patch that makes this transformation
is as follows: (http://coccinelle.lip6.fr/)

// 
@@
expression list es;
@@

-printk(
+WARN_ONCE(1,
  es);
-WARN_ON_ONCE(1);
// 

Signed-off-by: Julia Lawall 

---
 drivers/gpu/drm/drm_cache.c |9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
index a575cb2..8df9a7b 100644
--- a/drivers/gpu/drm/drm_cache.c
+++ b/drivers/gpu/drm/drm_cache.c
@@ -94,8 +94,7 @@ drm_clflush_pages(struct page *pages[], unsigned long 
num_pages)
kunmap_atomic(page_virtual);
}
 #else
-   printk(KERN_ERR "Architecture has no drm_cache.c support\n");
-   WARN_ON_ONCE(1);
+   WARN_ONCE(1, KERN_ERR "Architecture has no drm_cache.c support\n");
 #endif
 }
 EXPORT_SYMBOL(drm_clflush_pages);
@@ -119,8 +118,7 @@ drm_clflush_sg(struct sg_table *st)
if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
printk(KERN_ERR "Timed out waiting for cache flush.\n");
 #else
-   printk(KERN_ERR "Architecture has no drm_cache.c support\n");
-   WARN_ON_ONCE(1);
+   WARN_ONCE(1, KERN_ERR "Architecture has no drm_cache.c support\n");
 #endif
 }
 EXPORT_SYMBOL(drm_clflush_sg);
@@ -142,8 +140,7 @@ drm_clflush_virt_range(char *addr, unsigned long length)
if (on_each_cpu(drm_clflush_ipi_handler, NULL, 1) != 0)
printk(KERN_ERR "Timed out waiting for cache flush.\n");
 #else
-   printk(KERN_ERR "Architecture has no drm_cache.c support\n");
-   WARN_ON_ONCE(1);
+   WARN_ONCE(1, KERN_ERR "Architecture has no drm_cache.c support\n");
 #endif
 }
 EXPORT_SYMBOL(drm_clflush_virt_range);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 00/31] numa/core patches

2012-11-03 Thread Alex Shi
>
> In reality, this report is larger but I chopped it down a bit for
> brevity. autonuma beats schednuma *heavily* on this benchmark both in
> terms of average operations per numa node and overall throughput.
>
> SPECJBB PEAKS
>3.7.0  3.7.0   
>3.7.0
>   rc2-stats-v2r1 rc2-autonuma-v27r8   
>   rc2-schednuma-v1r3
>  Expctd Warehouse   12.00 (  0.00%)   12.00 ( 
>  0.00%)   12.00 (  0.00%)
>  Expctd Peak Bops   442225.00 (  0.00%)   596039.00 ( 
> 34.78%)   555342.00 ( 25.58%)
>  Actual Warehouse7.00 (  0.00%)9.00 ( 
> 28.57%)8.00 ( 14.29%)
>  Actual Peak Bops   550747.00 (  0.00%)   646124.00 ( 
> 17.32%)   560635.00 (  1.80%)

It is impressive report!

Could you like to share the what JVM and options are you using in the
testing, and based on which kinds of platform?

-- 
Thanks
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[GIT PULL] Thermal management & ACPI update for v3.7-rc4

2012-11-03 Thread Zhang Rui
Hi Linus,

Could you please pull from the git repository at

  git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git release

to receive three thermal and acpi fixes for v3.7-rc4.

thanks,
rui


The following changes since commit
1e207eb1c3f0e8b690401f02fe08e7b53903f010:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending
(2012-10-31 15:42:08 -0700)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git 

for you to fetch changes up to 2566285df1863f69a6552dbcd8f38153db8d2e15:

  exynos4_tmu_driver_ids should be exynos_tmu_driver_ids. (2012-11-01
09:21:54 +0800)


Devendra Naga (1):
  thermal: solve compilation errors in rcar_thermal

Igor Murzov (1):
  ACPI video: Ignore errors after _DOD evaluation.

Jonghwan Choi (1):
  exynos4_tmu_driver_ids should be exynos_tmu_driver_ids.

 drivers/acpi/video.c |   11 +++
 drivers/thermal/exynos_thermal.c |2 +-
 drivers/thermal/rcar_thermal.c   |2 +-
 3 files changed, 9 insertions(+), 6 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 10/16] drivers/net/ethernet/ibm/emac/mal.c: use WARN

2012-11-03 Thread walter harms


Am 03.11.2012 11:58, schrieb Julia Lawall:
> From: Julia Lawall 
> 
> Use WARN rather than printk followed by WARN_ON(1), for conciseness.
> 
> A simplified version of the semantic patch that makes this transformation
> is as follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> expression list es;
> @@
> 
> -printk(
> +WARN(1,
>   es);
> -WARN_ON(1);
> // 
> 
> Signed-off-by: Julia Lawall 
> 
> ---
>  drivers/net/ethernet/ibm/emac/mal.c |6 ++
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ibm/emac/mal.c 
> b/drivers/net/ethernet/ibm/emac/mal.c
> index 479e43e..84c6b6c 100644
> --- a/drivers/net/ethernet/ibm/emac/mal.c
> +++ b/drivers/net/ethernet/ibm/emac/mal.c
> @@ -738,13 +738,11 @@ static int __devexit mal_remove(struct platform_device 
> *ofdev)
>   /* Synchronize with scheduled polling */
>   napi_disable(&mal->napi);
>  
> - if (!list_empty(&mal->list)) {
> + if (!list_empty(&mal->list))
>   /* This is *very* bad */
> - printk(KERN_EMERG
> + WARN(1, KERN_EMERG
>  "mal%d: commac list is not empty on remove!\n",
>  mal->index);
> - WARN_ON(1);
> - }
>  
>   dev_set_drvdata(&ofdev->dev, NULL);
>  
> 

Hi Julia,
you are removing the {} behin the if. I prefer to be a bit conservative
about {}. There is suggest to keep them because WARN may be expanded in
future (with a second line) and that will cause subtle changes that do
no break the code. (Yes i know it is possible to write macros that
contain savely more than one line.)

re,
 wh

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Fwd: Nice processes prevent frequency increases - possible scheduler regression (known good in 2.6.35)

2012-11-03 Thread Mike Galbraith
On Fri, 2012-11-02 at 21:09 +0100, Michal Zatloukal wrote:

> On the new kernel, the nice processes are never starved - even when
> starting a tab-laden chromium session, the processes for BOINC keep
> about 20% CPU each (that is normalized to all CPUs, ie 40% nice load
> on each core). The problem is, the governor now seems to consider the
> non-nice task unable to saturate the CPU, and the cores' frequencies
> are hovering between 1.0 and 1.8 GHz. The scheduler keeps scheduling
> the nice tasks, and the non-nice tasks are progressing much slower,
> caused by the lower CPU speed as well as less processing time
> allocated to them. HD video stutters often, and Chromium takes at
> least 2-3 times longer to fully load.

Your nice 19 tasks receiving 'too much' CPU when there are other
runnable tasks around sounds like you have SCHED_AUTOGROUP enabled.

With this enabled (or if tasks are placed in cgroups by another means),
group A and group B will each receive equal CPU if group shares/weight
are equal, regardless of group content.  Task nice level will affect CPU
distribution within a group, but group A containing a gaggle of nice 19
tasks will receive the same amount of CPU as group B containing your
nice 0 browser with zillion tabs.  Add nice 0 hogs to group A, the nice
19 tasks will receive much less CPU, but the total for group A will
remain unchanged relative to group B, unless group shares/weights are
twiddled.

(no idea what's going on with ondemand)

-Mike

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[git pull] drm fixes

2012-11-03 Thread Dave Airlie

Hi Linus,

scattered selection of fixes:
radeon: load detect fixes from SuSE/AMD
intel: misc i830, sdvo regression, vesafb kickoff ums fix
exynos: maintainers entry update + fixes
udl: fix stride scanout issue

its slightly bigger than I'd probably like, but nothing looked dangerous 
enough to hold off on.

Dave.

The following changes since commit 4936b172d699434547addbe452c2d600ea6a4baf:

  Merge branch 'drm-nouveau-fixes' of 
git://people.freedesktop.org/git/nouveau/linux-2.6 into drm-fixes (2012-10-31 
13:46:09 +1000)

are available in the git repository at:

  git://people.freedesktop.org/~airlied/linux drm-fixes

Alex Deucher (1):
  drm/radeon: add load detection support for ext DAC on R200 (v2)

Chris Wilson (1):
  drm/i915: Only kick out vesafb if we takeover the fbcon with KMS

Daniel Vetter (3):
  drm/i915: fix overlay on i830M
  drm/i915: VGA needs to be on pipe A on i830M
  drm/i915: clear the entire sdvo infoframe buffer

Dave Airlie (4):
  Merge branch 'drm-intel-fixes' of 
git://people.freedesktop.org/~danvet/drm-intel into drm-fixes
  Merge branch 'drm-fixes-3.7' of git://people.freedesktop.org/~agd5f/linux 
into drm-fixes
  Merge branch 'exynos-drm-fixes' of 
git://git.kernel.org/.../daeinki/drm-exynos into drm-fixes
  drm/udl: fix stride issues scanning out stride != width*bpp

Egbert Eich (6):
  DRM/Radeon: Fix Load Detection on legacy primary DAC.
  DRM/Radeon: Fix primary DAC Load Detection for RV100 chips.
  DRM/Radeon: On DVI-I use Load Detection when EDID is bogus.
  DRM/Radeon: Clean up code in TV DAC load detection.
  DRM/Radeon: Fix TV DAC Load Detection for single CRTC chips.
  DRM/radeon: For single CRTC GPUs move handling of CRTC_CRT_ON to 
crtc_dpms().

Igor Murzov (1):
  drm/radeon: fix ATPX function documentation

Inki Dae (2):
  drm/exynos: fix display on issue
  MAINTAINERS: Add git repository for Exynos DRM

Jani Nikula (1):
  drm/i915: be less verbose about inability to provide vendor backlight

Peter Senna Tschudin (1):
  drivers/gpu/drm/radeon/evergreen_cs.c: Remove unnecessary semicolon

Rahul Sharma (1):
  drm: exynos: removed warning due to missing typecast for mixer driver data

Rob Clark (1):
  drm/exynos: add support for ARCH_MULTIPLATFORM

 MAINTAINERS |1 +
 drivers/gpu/drm/exynos/Kconfig  |2 +-
 drivers/gpu/drm/exynos/exynos_drm_connector.c   |1 +
 drivers/gpu/drm/exynos/exynos_drm_encoder.c |   33 +++--
 drivers/gpu/drm/exynos/exynos_mixer.c   |2 +-
 drivers/gpu/drm/i915/i915_dma.c |3 +-
 drivers/gpu/drm/i915/intel_crt.c|2 +-
 drivers/gpu/drm/i915/intel_overlay.c|   14 ++-
 drivers/gpu/drm/i915/intel_panel.c  |2 +-
 drivers/gpu/drm/i915/intel_sdvo.c   |   62 ++---
 drivers/gpu/drm/i915/intel_sdvo_regs.h  |2 +
 drivers/gpu/drm/radeon/evergreen_cs.c   |2 +-
 drivers/gpu/drm/radeon/radeon_atpx_handler.c|4 +-
 drivers/gpu/drm/radeon/radeon_connectors.c  |   28 +++-
 drivers/gpu/drm/radeon/radeon_legacy_crtc.c |   15 ++-
 drivers/gpu/drm/radeon/radeon_legacy_encoders.c |  175 +++
 drivers/gpu/drm/udl/udl_drv.h   |2 +-
 drivers/gpu/drm/udl/udl_fb.c|   12 +-
 drivers/gpu/drm/udl/udl_transfer.c  |5 +-
 19 files changed, 275 insertions(+), 92 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [ 0/4] 3.0.51-stable review

2012-11-03 Thread Rafael Aquini
On Fri, Nov 02, 2012 at 09:07:11PM -0700, Greg Kroah-Hartman wrote:
> > 
> > Howdy Greg,
> > 
> > Somehow the following patch is missing for this series submission:
> > > Len Brown 
> > > x86: Remove the ancient and deprecated disable_hlt() and enable_hlt() 
> > > facility
> > 
> > I glanced at the the downloadable consolidated patch and its hunks seem to 
> > be present,
> > though.
> 
> I do not understand.  Where do you not see it?  It's in the patch on
> kernel.org, right?  Where is it missing?
> 

The LKML patch series is missing PATCH 02/04.



> confused,
> 
> greg k-h
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: Fwd: Nice processes prevent frequency increases - possible scheduler regression (known good in 2.6.35)

2012-11-03 Thread Mike Galbraith
On Sat, 2012-11-03 at 04:33 -0700, Mike Galbraith wrote: 
> On Fri, 2012-11-02 at 21:09 +0100, Michal Zatloukal wrote:
> 
> > On the new kernel, the nice processes are never starved - even when
> > starting a tab-laden chromium session, the processes for BOINC keep
> > about 20% CPU each (that is normalized to all CPUs, ie 40% nice load
> > on each core). The problem is, the governor now seems to consider the
> > non-nice task unable to saturate the CPU, and the cores' frequencies
> > are hovering between 1.0 and 1.8 GHz. The scheduler keeps scheduling
> > the nice tasks, and the non-nice tasks are progressing much slower,
> > caused by the lower CPU speed as well as less processing time
> > allocated to them. HD video stutters often, and Chromium takes at
> > least 2-3 times longer to fully load.
> 
> Your nice 19 tasks receiving 'too much' CPU when there are other
> runnable tasks around sounds like you have SCHED_AUTOGROUP enabled.

(forgot to mention: if that's the case, you can add noautogroup to your
kernel command line to turn it off if distro turned it on in .config)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 0/3] capebus moving omap_devices to mach-omap2

2012-11-03 Thread Kevin Hilman

On 11/02/2012 09:43 AM, Pantelis Antoniou wrote:
[...]



And then use the standard DT support to create later the platform_device that 
does represent the new super-cape devices.



We know this is the ideal case. In fact that's the long term goal and we had 
internal discussions about it.


Since you already had internal discussions about this, it would have 
been a great help in avoiding lots of this discussion if you would've 
summarized this ideal case from the beginning, then describe the 
weaknesses and limitations of DT for handling hotplug/dynamic devices 
and thus the reasoning behind creating capebus.  Now it's taken this 
long thread for others to try to convince you about something you 
already knew to be the ideal case.  Seems a bit wasteful.


Kernel development typically works by building/extending infrastructure 
that is already there.  Only when it's obvious that the current 
infrastructure cannot be extended for a new kind of usage do we build 
new infrastruture.


In this case, DT is the obvious infrastructure that needs extending.  At 
least we can all agree on that, for starters.



DT is nowhere near being able to do it.

That would require the introduction of a DT object file format with aliases 
being capable to be
resolved dynamically. We're talking about major changes here in the way DT 
files are being compiled and
used in practice.

So yes, in an ideal world that would be great. We're nowhere near close today 
unfortunately.

Assuming that we do work on a DT object format, and that the runtime resolution 
mechanism is approved,
then I agree that this part of the capebus patches can be dropped and the 
functionality assumed by generic
DT core.

The question is that this will take time, with no guarantees that this would be 
acceptable from
the device tree maintainers. So I am putting them in the CC list, to see what 
they think about it.


Since this thread has already ventured into the weeds a few times, I 
would suggest that you summarize the DT limitations (focusing on they 
dynamic/hotplug needs) and start a thread on devicetree-discuss, so that 
the DT maintainers can be helpful without having to follow this thread.


IMO, the path forward is clear (though probably longer than you would 
like):  Let's first try and extend DT infrastructure.  If that is 
obviously going nowhere, and DT maintainers are against it.  Then, let's 
revisit capebus.


Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v2] proc: add "Seccomp" to status

2012-11-03 Thread Vasiliy Kulikov
On Thu, Nov 01, 2012 at 11:35 -0700, Kees Cook wrote:
> @@ -327,6 +327,13 @@ static inline void task_cap(struct seq_file *m, struct 
> task_struct *p)
>   render_cap_t(m, "CapBnd:\t", &cap_bset);
>  }
>  
> +static inline void task_seccomp(struct seq_file *m, struct task_struct *p)
> +{
> +#ifdef CONFIG_SECCOMP
> + seq_printf(m, "Seccomp:\t%d\n", p->seccomp.mode);
> +#endif

Hmm, probably it's better to always show this line, not only on
SECCOMP'ed kernel?  If it is disabled just print "0".  It will simplify
parsing of /proc/pid/status.

> +}
> +
>  static inline void task_context_switch_counts(struct seq_file *m,
>   struct task_struct *p)
>  {

Thanks,

-- 
Vasiliy Kulikov
http://www.openwall.com - bringing security into open computing environments
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] Second attempt at kernel secure boot support

2012-11-03 Thread James Bottomley
On Sat, 2012-11-03 at 00:22 +, Matthew Garrett wrote:
> On Fri, Nov 02, 2012 at 11:38:23PM +, James Bottomley wrote:
> > On Fri, 2012-11-02 at 18:04 +, Matthew Garrett wrote:
> > > A user runs a binary that elevates itself to admin. Absent any flaws in 
> > > Windows (cough), that should be all it can do in a Secure Boot world. 
> > > But if you can drop a small trusted Linux system in there and use that 
> > > to boot a compromised Windows kernel, it can make itself persistent.
> > 
> > We seem to be talking past each other.  Assume you managed to install a
> > Linux boot system on the windows machine.  If the linux boot requires
> > present user on first boot (either because the key of the bootloader
> > isn't in db or because the MOK database isn't initialised), you still
> > don't have a compromise because the loader won't start automatically.
> 
> Why would an attacker use one of those Linux systems? There's going to 
> be plenty available that don't have that restriction.

It's called best practices.  If someone else releases something that
doesn't conform to them, then it's their signing key in jeopardy, not
yours.  You surely must see that the goal of securing "everything"
against "anything" isn't achievable because if someone releases a
bootloader not conforming to the best practices, why would they have
bothered to include your secure boot lockdowns in their kernel.  In
other words, you lost ab initio, so it's pointless to cite this type of
thing as a rationale for a kernel lockdown patch.

James



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 04/11] clk: davinci - add pll divider clock driver

2012-11-03 Thread Sekhar Nori
On 11/2/2012 7:23 PM, Murali Karicheri wrote:
> On 11/02/2012 07:33 AM, Sekhar Nori wrote:
>> On 10/25/2012 9:41 PM, Murali Karicheri wrote:
>>
>>> pll dividers are present in the pll controller of DaVinci and Other
>>> SoCs that re-uses the same hardware IP. This has a enable bit for
>>> bypass the divider or enable the driver. This is a sub class of the
>>> clk-divider clock checks the enable bit to calculare the rate and
>>> invoke the recalculate() function of the clk-divider if enabled.
>>>
>>> Signed-off-by: Murali Karicheri 
>>> ---

>>> +/**
>>> + * clk_register_davinci_plldiv - register function for DaVinci PLL
>>> divider clk
>>> + *
>>> + * @dev: device ptr
>>> + * @name: name of the clock
>>> + * @parent_name: name of parent clock
>>> + * @plldiv_data: ptr to pll divider data
>>> + * @lock: ptr to spinlock passed to divider clock
>>> + */
>>> +struct clk *clk_register_davinci_plldiv(struct device *dev,
>> Why do you need a dev pointer here and which device does it point to? In
>> the only usage of this API in the series, you pass a NULL here. I should
>> have probably asked this question on one of the earlier patches itself.
>>
> I did a grep in the drivers/clk directory. All of the platform drivers
> are having the device ptr and all of them are called with NULL. I am not
> sure what is the intent of this arg in the API.  As per documentation of

I just took a look at the mxs example you referenced below and it does
not take a dev pointer.

struct clk *mxs_clk_div(const char *name, const char *parent_name,
void __iomem *reg, u8 shift, u8 width, u8 busy)
{

> the clk_register() API, the device ptr points to the device that is
> registering this clk. So if a specific device driver ever has to
> register a PLL div clk, this will be non NULL. In  the normal use case,
> clk is registered in a platform specific code and is always passed NULL.
> 
> The platform/SoC specific clock initialization code will be using
> davinci_plldiv_clk() that doesn't have a device ptr arg.
> So this can be changed in future in sync with other drivers (assuming
> this will get removed if unused), and changes
> doesn't impact the platform code that initialize the clock. So IMO, we
> should keep this arg so that it is in sync with other driver APIs.

I think you should get rid of this unused arg and introduce it when you
actually need it. That way we are clear about why we need it.

> 
> +const char *name, const char *parent_name,
> +struct clk_plldiv_data *plldiv_data,
> +spinlock_t *lock)
> +{
> +struct clk_div *div;
> +struct clk *clk;
> +struct clk_init_data init;
> +
> +div = kzalloc(sizeof(*div), GFP_KERNEL);
> +if (!div)
> +return ERR_PTR(-ENOMEM);
> +
> +init.name = name;
> +init.ops = &clk_div_ops;
> +init.flags = plldiv_data->flags;
> +init.parent_names = (parent_name ? &parent_name : NULL);
> +init.num_parents = (parent_name ? 1 : 0);
> +
> +div->reg = plldiv_data->reg;
> +div->en_id = plldiv_data->en_id;
> +
> +div->divider.reg = plldiv_data->reg;
> +div->divider.shift = plldiv_data->shift;
> +div->divider.width = plldiv_data->width;
> +div->divider.flags = plldiv_data->divider_flags;
> +div->divider.lock = lock;
> +div->divider.hw.init = &init;
> +div->ops = &clk_divider_ops;
> +
> +clk = clk_register(NULL, &div->divider.hw);
> 
>> Shouldn't you be calling clk_register_divider() here which in turn will
>> do clk_register()?
> As stated in the top of the file, this is a subclass driver of clk-div
> similar in line with mxs/clk-div.c. The
> driver registers the clock instead of calling clk_register_divider() so
> that it's ops function has a chance to do whatever it wants to do and
> call the divider ops function after that.

I see that now. I should have paid more attention.

Regards,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 02/11] clk: davinci - add PSC clock driver

2012-11-03 Thread Sekhar Nori
On 10/25/2012 9:41 PM, Murali Karicheri wrote:
> This is the driver for the Power Sleep Controller (PSC) hardware
> found on DM SoCs as well Keystone SoCs (c6x). This driver borrowed
> code from arch/arm/mach-davinci/psc.c and implemented the driver
> as per common clock provider API. The PSC module is responsible for
> enabling/disabling the Power Domain and Clock domain for different IPs
> present in the SoC. The driver is configured through the clock data
> passed to the driver through struct clk_psc_data.
> 
> Signed-off-by: Murali Karicheri 
> ---

> +/**
> + * struct clk_psc - DaVinci PSC clock driver data
> + *
> + * @hw: clk_hw for the psc
> + * @psc_data: Driver specific data
> + */
> +struct clk_psc {
> + struct clk_hw hw;
> + struct clk_psc_data *psc_data;

> + spinlock_t *lock;

Unused member? I don't see this being used.

Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 11/16] drivers/misc/kgdbts.c: use WARN

2012-11-03 Thread walter harms


Am 03.11.2012 11:58, schrieb Julia Lawall:
> From: Julia Lawall 
> 
> Use WARN rather than printk followed by WARN_ON(1), for conciseness.
> 
> A simplified version of the semantic patch that makes this transformation
> is as follows: (http://coccinelle.lip6.fr/)
> 
> // 
> @@
> expression list es;
> @@
> 
> -printk(
> +WARN(1,
>   es);
> -WARN_ON(1);
> // 
> 
> Signed-off-by: Julia Lawall 
> 
> ---
>  drivers/misc/kgdbts.c |5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
> index 3aa9a96..8b367db 100644
> --- a/drivers/misc/kgdbts.c
> +++ b/drivers/misc/kgdbts.c
> @@ -114,9 +114,8 @@
>   touch_nmi_watchdog();   \
>   } while (0)
>  #define eprintk(a...) do { \
> - printk(KERN_ERR a); \
> - WARN_ON(1); \
> - } while (0)
> + WARN(1, KERN_ERR a); \
> + } while (0)
>  #define MAX_CONFIG_LEN   40
>  

A macro calling a macro ?
Is it possible to replace eprintk() ?

re,
 wh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


RE: [Xen-devel] [PATCH 1/2] Xen acpi pad implement

2012-11-03 Thread Liu, Jinsong
Konrad Rzeszutek Wilk wrote:
>>> From f514b97628945cfac00efb0d456f133d44754c9d Mon Sep 17 00:00:00
>>> 2001 
>> From: Liu, Jinsong 
>> Date: Thu, 1 Nov 2012 21:02:36 +0800
>> Subject: [PATCH 1/2] Xen acpi pad implement
>> 
>> PAD is acpi Processor Aggregator Device which provides a control
>> point 
>> that enables the platform to perform specific processor configuration
>> and control that applies to all processors in the platform.
>> 
>> This patch is to implement Xen acpi pad logic. When running under Xen
>> virt platform, native pad driver would not work. Instead Xen pad
>> driver, 
>> a self-contained and very thin logic level, would take over acpi pad
>> staff. When acpi pad notify OSPM, xen pad logic intercept and parse
>> _PUR object 
>> and then hypercall to hyervisor for the rest work, say, core parking.
> 
> Two comments:
>  - Did you look at the SuSE tree? Jan mentioned that they did some
>fixes? Did you carry them over?

I didn't look at Suse tree.

Jan, would you please tell me where can I pull Suse tree? have you implemented 
xen-acpi-pad logic at Suse dom0 and which points you have fixed?


>  - The init function should not make hypercalls before checking if it
>in facts run under Xen.

OK.

>> +
>> +static const struct acpi_device_id pad_device_ids[] = {
>> +{"ACPI000C", 0}, +  {"", 0},
>> +};
>> +
>> +static struct acpi_driver xen_acpi_pad_driver = {
>> +.name = "processor_aggregator",
>> +.class = ACPI_PROCESSOR_AGGREGATOR_CLASS,
>> +.ids = pad_device_ids,
>> +.ops = {
>> +.add = xen_acpi_pad_add,
>> +.remove = xen_acpi_pad_remove,
>> +},
>> +};
>> +
>> +static int __init xen_acpi_pad_init(void)
>> +{
>> +int ret = -ENOSYS;
>> +unsigned int version = HYPERVISOR_xen_version(XENVER_version,
>> NULL); 
> 
> Heh. so if you run this on baremetal I wonder what will happen.
> 
>> +unsigned int major = version >> 16;
>> +unsigned int minor = version & 0x;
>> +
>> +/* Only DOM0 is responsible for Xen acpi pad */
>> +if (!xen_initial_domain())
>> +return -ENODEV;
>> +
> 
> I think the check for version should happen here.

Got it, will update later.

Thanks,
Jinsong

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 00/31] numa/core patches

2012-11-03 Thread Mel Gorman
On Sat, Nov 03, 2012 at 07:04:04PM +0800, Alex Shi wrote:
> >
> > In reality, this report is larger but I chopped it down a bit for
> > brevity. autonuma beats schednuma *heavily* on this benchmark both in
> > terms of average operations per numa node and overall throughput.
> >
> > SPECJBB PEAKS
> >3.7.0  3.7.0 
> >  3.7.0
> >   rc2-stats-v2r1 rc2-autonuma-v27r8 
> > rc2-schednuma-v1r3
> >  Expctd Warehouse   12.00 (  0.00%)   12.00 
> > (  0.00%)   12.00 (  0.00%)
> >  Expctd Peak Bops   442225.00 (  0.00%)   596039.00 
> > ( 34.78%)   555342.00 ( 25.58%)
> >  Actual Warehouse7.00 (  0.00%)9.00 
> > ( 28.57%)8.00 ( 14.29%)
> >  Actual Peak Bops   550747.00 (  0.00%)   646124.00 
> > ( 17.32%)   560635.00 (  1.80%)
> 
> It is impressive report!
> 
> Could you like to share the what JVM and options are you using in the
> testing, and based on which kinds of platform?
> 

Oracle JVM version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

4 JVMs were run, one for each node.

JVM switch specified was -Xmx12901m so it would consume roughly 80% of
memory overall.

Machine is x86-64 4-node, 64G of RAM, CPUs are E7-4807, 48 cores in
total with HT enabled.

-- 
Mel Gorman
SUSE Labs
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 03/11] clk: davinci - common clk utilities to init clk driver

2012-11-03 Thread Sekhar Nori
On 10/25/2012 9:41 PM, Murali Karicheri wrote:
> This is the common clk driver initialization functions for DaVinci
> SoCs and other SoCs that uses similar hardware architecture.
> clock.h also defines struct types for clock definitions in a SoC
> and clock data type for configuring clk-mux. The initialization
> functions are used by clock initialization code in a specific
> platform/SoC.
> 
> Signed-off-by: Murali Karicheri 
> ---
>  drivers/clk/davinci/clock.c |  112 
> +++
>  drivers/clk/davinci/clock.h |   80 +++
>  2 files changed, 192 insertions(+)
>  create mode 100644 drivers/clk/davinci/clock.c
>  create mode 100644 drivers/clk/davinci/clock.h
> 
> diff --git a/drivers/clk/davinci/clock.c b/drivers/clk/davinci/clock.c
> new file mode 100644
> index 000..ad02149
> --- /dev/null
> +++ b/drivers/clk/davinci/clock.c
> @@ -0,0 +1,112 @@
> +/*
> + * clock.c - davinci clock initialization functions for various clocks
> + *
> + * Copyright (C) 2006-2012 Texas Instruments.
> + * Copyright (C) 2008-2009 Deep Root Systems, LLC
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + */
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "clk-pll.h"
> +#include "clk-psc.h"
> +#include "clk-div.h"
> +#include "clock.h"
> +
> +static DEFINE_SPINLOCK(_lock);
> +
> +#ifdef   CONFIG_CLK_DAVINCI_PLL
> +struct clk *davinci_pll_clk(const char *name, const char *parent,
> + u32 phys_pllm, u32 phys_prediv, u32 phys_postdiv,
> + struct clk_pll_data *pll_data)
> +{
> + struct clk *clkp = NULL;
> +
> + pll_data->reg_pllm = ioremap(phys_pllm, 4);
> + if (WARN_ON(!pll_data->reg_pllm))
> + return clkp;

I would prefer ERR_PTR(-ENOMEM) here. Same comment applies to other
instances elsewhere in the patch.

> diff --git a/drivers/clk/davinci/clock.h b/drivers/clk/davinci/clock.h
> new file mode 100644
> index 000..73204b8
> --- /dev/null
> +++ b/drivers/clk/davinci/clock.h
> @@ -0,0 +1,80 @@
> +/*
> + * TI DaVinci Clock definitions -  Contains Macros and Types used for
> + * defining various clocks on a DaVinci SoC
> + *
> + * Copyright (C) 2012 Texas Instruments
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation version 2.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#ifndef __DAVINCI_CLOCK_H
> +#define __DAVINCI_CLOCK_H
> +
> +#include 
> +
> +/* general flags: */
> +#define ALWAYS_ENABLED   BIT(0)

This is not used in this patch. Can you add the define along with its
usage so it is immediately clear why you need it?

> +/**
> + * struct davinci_clk - struct for defining DaVinci clocks for a SoC.
> + *
> + * @name: name of the clock
> + * @parent: name of parent clock
> + * @flags: General flags for all drivers used by platform clock init code
> + * @data: data specific to a clock used by the driver
> + * @dev_id: dev_id used to look up this clock. If this is NULL
> + *   clock name is used for lookup.
> + */
> +struct davinci_clk {
> + const char  *name;
> + const char  *parent;
> + u32 flags;
> + void*data;
> + char*dev_id;

Similarly dont see this being used as well.

Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 8/16] drivers/infiniband/hw/cxgb3/iwch_cm.c: use WARN

2012-11-03 Thread Steve Wise


Acked-by: Steve Wise 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 6/16] drivers/infiniband/hw/cxgb4/cm.c: use WARN

2012-11-03 Thread Steve Wise

Acked-by: Steve Wise 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: setting up CDB filters in udev (was Re: [PATCH v2 0/3] block: add queue-private command filter, editable via sysfs)

2012-11-03 Thread Paolo Bonzini
Il 02/11/2012 18:53, Tejun Heo ha scritto:
> Hello, Paolo.
> 
> On Fri, Nov 02, 2012 at 06:49:43PM +0100, Paolo Bonzini wrote:
>>> No rule is really absolute.  To me, it seems the suggested in-kernel
>>> per-device command code filter is both too big for the given problem
>>
>> Is it?  150 lines of code?  The per-class filters would share the first
>> two patches with this series, add a long list of commands to filter, and
>> the ioctl would be on top of that.
> 
> It's not really about the lines of code.  It adds a new userland
> visible interface.  As for the "long" list of commands, it depends on
> how you write it but even if it's textually long it's still very
> simple in terms of actual complexity.

Sure, but its place is not the kernel.

As to implementing the ioctl, it's all but trivial.  For one thing, you
have to make the block device ioctl op take a "struct file".  I have
been asking Al Viro about it for 6 months and I haven't got any answer yet.

Second, getting a security-sensitive ioctl right is hard, as you
demonstrated yourself in this thread by proposing a gapingly insecure
approach.  Adding a little bit of customization to the current solution
may be but a local optimum, but you cannot really get it wrong.

>>> while being too limited for much beyond that.
>>
>> What are the use cases beyond these?  AFAIK these were the first two in
>> ten years or so...
> 
> If this is such a cold area, why do we want do anything other than the
> simplest possible?

Because _this_ is the simplest possible.

I proposed a way to implement the ultimately flexible solution (BPF) and
you shot it down because it was too complex.  Alan is showing you with
multiple examples of why the flexibility would be useful (perhaps nobody
would use it, but the use cases _are_ there), and you are mostly
ignoring them.

James suggested the sysfs knob, which is not as flexible but is the
simplest thing that can work, and was even part of the original design.
 You are still shooting it down because it is too complex, yet you're
proposing to replace one simple mechanism with two; one of which is
absolutely inflexible (unlike MMC which only has "ripping" and
"burning", other device classes have many use cases), while the other is
hard to both implement and get right.

Sounds great...

Paolo

>>> So, if we can get away
>>> with adding an ioctl, I personally think that would be a better
>>> approach.
>>
>> I would really prefer to get a green light from Jens/James for per-class
>> filters in the kernel (which are worth a few hundred lines of data)
>> before implementing that.
> 
> Sure, Jens, James?  Guys, come on.
> 
> Thanks.
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH v3 05/11] clk: davinci - add dm644x clock initialization

2012-11-03 Thread Sekhar Nori
On 10/25/2012 9:41 PM, Murali Karicheri wrote:
> This patch adds dm644x clock initialization code that consists of
> clocks data for various clocks and clock register callouts to
> various clock drivers. It uses following clk drivers for this
> 
>  1. clk-fixed-rate - for ref clock
>  2. clk-mux - for mux at the input and output of main pll
>  3. davinci specific clk-pll for main pll clock
>  4. davinci specific clk-div for pll divider clock
>  5. clk-fixed-factor for fixed factor clock such as auxclk
>  6. davinci specific clk-psc for psc clocks
> 
> This patch also moves all of the PLL and PSC register definitions
> from clock.h and psc.h under davinci to the clk/davinci folder so
> that various soc specific clock initialization code can share these
> definitions.

Except this patch does not move the defines, it creates a copy of them
(which is bad since you quickly lose track of which is the correct
copy). Is this done to avoid including mach/ header files here? It will
actually be better to include the mach/ files here as a temporary
solution and then remove the include mach/ files once all the SoCs have
been converted over.

> Signed-off-by: Murali Karicheri 
> ---
>  drivers/clk/davinci/dm644x-clock.c |  304 
> 
>  drivers/clk/davinci/pll.h  |   83 ++
>  drivers/clk/davinci/psc.h  |  215 +
>  3 files changed, 602 insertions(+)
>  create mode 100644 drivers/clk/davinci/dm644x-clock.c
>  create mode 100644 drivers/clk/davinci/pll.h
>  create mode 100644 drivers/clk/davinci/psc.h
> 

> +/* all clocks available in DM644x SoCs */
> +enum dm644x_clk {
> + clkin, oscin, ref_clk_mux, pll1, pll1_plldiv_clk_mux, auxclk,
> + clk_pll1_sysclk1, clk_pll1_sysclk2, clk_pll1_sysclk3, clk_pll1_sysclk4,
> + clk_pll1_sysclk5, clk_pll1_sysclkbp, pll2, pll2_plldiv_clk_mux,
> + clk_pll2_sysclk1, clk_pll2_sysclk2, clk_pll2_sysclkbp, dsp, arm, vicp,
> + vpss_master, vpss_slave, uart0, uart1, uart2, emac, i2c, ide, asp,
> + mmcsd, spi, gpio, usb, vlynq, aemif, pwm0, pwm1, pwm2, timer0, timer1,
> + timer2, clk_max
> +};
> +
> +static struct davinci_clk *psc_clocks[] = {
> + &clk_dsp, &clk_arm, &clk_vicp, &clk_vpss_master, &clk_vpss_slave,
> + &clk_uart0, &clk_uart1, &clk_uart2, &clk_emac, &clk_i2c, &clk_ide,
> + &clk_asp0, &clk_mmcsd, &clk_spi, &clk_gpio, &clk_usb, &clk_vlynq,
> + &clk_aemif, &clk_pwm0, &clk_pwm1, &clk_pwm2, &clk_timer0, &clk_timer1,
> + &clk_timer2
> +};

You rely on perfect order between this array and dm644x_clk enum above.
Can you initialize this array using the enum as the index so that it is
clear. Current method is too error prone.

Thanks,
Sekhar
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging/comedi: Use dev_ printks in drivers/adl_pci9118.c

2012-11-03 Thread YAMANE Toshiaki
fixed below checkpatch warnings.
- WARNING: Prefer netdev_err(netdev, ... then dev_err(dev, ... then pr_err(...  
to printk(KERN_ERR ...

Signed-off-by: YAMANE Toshiaki 
---
 drivers/staging/comedi/drivers/adl_pci9118.c |   31 ++
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/comedi/drivers/adl_pci9118.c 
b/drivers/staging/comedi/drivers/adl_pci9118.c
index a5d0be2..e9d45c2 100644
--- a/drivers/staging/comedi/drivers/adl_pci9118.c
+++ b/drivers/staging/comedi/drivers/adl_pci9118.c
@@ -1888,7 +1888,7 @@ static struct pci_dev *pci9118_find_pci(struct 
comedi_device *dev,
 */
if (comedi_pci_enable(pcidev, "adl_pci9118"))
continue;
-   printk(KERN_ERR ", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx",
+   dev_err(dev->class_dev, ", b:s:f=%d:%d:%d, io=0x%4lx, 0x%4lx",
pcidev->bus->number,
PCI_SLOT(pcidev->devfn),
PCI_FUNC(pcidev->devfn),
@@ -1896,9 +1896,9 @@ static struct pci_dev *pci9118_find_pci(struct 
comedi_device *dev,
(unsigned long)pci_resource_start(pcidev, 0));
return pcidev;
}
-   printk(KERN_ERR
-   "comedi%d: no supported board found! (req. bus/slot : %d/%d)\n",
-   dev->minor, bus, slot);
+   dev_err(dev->class_dev,
+   "no supported board found! (req. bus/slot : %d/%d)\n",
+   bus, slot);
return NULL;
 }
 
@@ -1914,7 +1914,7 @@ static int pci9118_attach(struct comedi_device *dev,
unsigned int irq;
u16 u16w;
 
-   printk("comedi%d: adl_pci9118: board=%s", dev->minor, this_board->name);
+   dev_dbg(dev->class_dev, "board=%s", this_board->name);
 
if (it->options[3] & 1)
master = 0; /* user don't want use bus master */
@@ -1947,14 +1947,15 @@ static int pci9118_attach(struct comedi_device *dev,
if (irq > 0) {
if (request_irq(irq, interrupt_pci9118, IRQF_SHARED,
"ADLink PCI-9118", dev)) {
-   printk(", unable to allocate IRQ %d, DISABLING IT",
-  irq);
+   dev_dbg(dev->class_dev,
+   ", unable to allocate IRQ %d, DISABLING IT",
+   irq);
irq = 0;/* Can't use IRQ */
} else {
-   printk(", irq=%u", irq);
+   dev_dbg(dev->class_dev, ", irq=%u", irq);
}
} else {
-   printk(", IRQ disabled");
+   dev_dbg(dev->class_dev, ", IRQ disabled");
}
 
dev->irq = irq;
@@ -1980,7 +1981,8 @@ static int pci9118_attach(struct comedi_device *dev,
}
}
if (!devpriv->dmabuf_virt[0]) {
-   printk(", Can't allocate DMA buffer, DMA disabled!");
+   dev_dbg(dev->class_dev,
+   ", Can't allocate DMA buffer, DMA disabled!");
master = 0;
}
 
@@ -1991,9 +1993,9 @@ static int pci9118_attach(struct comedi_device *dev,
 
devpriv->master = master;
if (devpriv->master)
-   printk(", bus master");
+   dev_dbg(dev->class_dev, ", bus master");
else
-   printk(", no bus master");
+   dev_dbg(dev->class_dev, ", no bus master");
 
devpriv->usemux = 0;
if (it->options[2] > 0) {
@@ -2005,7 +2007,8 @@ static int pci9118_attach(struct comedi_device *dev,
devpriv->usemux = 128;
/* max 128 channels with softare S&H! */
}
-   printk(", ext. mux %d channels", devpriv->usemux);
+   dev_dbg(dev->class_dev,
+   ", ext. mux %d channels", devpriv->usemux);
}
 
devpriv->softsshdelay = it->options[4];
@@ -2019,7 +2022,7 @@ static int pci9118_attach(struct comedi_device *dev,
devpriv->softsshhold = 0x80;
}
 
-   printk(".\n");
+   dev_dbg(dev->class_dev, ".\n");
 
pci_read_config_word(pcidev, PCI_COMMAND, &u16w);
pci_write_config_word(pcidev, PCI_COMMAND, u16w | 64);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging/comedi: fix the spaces issue around that '=' in drivers/ni_670x.c

2012-11-03 Thread YAMANE Toshiaki
fixed below checkpatch error.
- ERROR: spaces required around that '=' (ctx:WxV)

Signed-off-by: YAMANE Toshiaki 
---
 drivers/staging/comedi/drivers/ni_670x.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/ni_670x.c 
b/drivers/staging/comedi/drivers/ni_670x.c
index 36462d5..7a72131 100644
--- a/drivers/staging/comedi/drivers/ni_670x.c
+++ b/drivers/staging/comedi/drivers/ni_670x.c
@@ -322,7 +322,7 @@ static DEFINE_PCI_DEVICE_TABLE(ni_670x_pci_table) = {
 MODULE_DEVICE_TABLE(pci, ni_670x_pci_table);
 
 static struct pci_driver ni_670x_pci_driver = {
-   .name   ="ni_670x",
+   .name   = "ni_670x",
.id_table   = ni_670x_pci_table,
.probe  = ni_670x_pci_probe,
.remove = __devexit_p(ni_670x_pci_remove),
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging/comedi: Use dev_ printks in drivers/comedi_fc.c

2012-11-03 Thread YAMANE Toshiaki
fixed below checkpatch warning.
- WARNING: Prefer netdev_warn(netdev, ... then dev_warn(dev, ... then 
pr_warn(...  to printk(KERN_WARNING ...

Signed-off-by: YAMANE Toshiaki 
---
 drivers/staging/comedi/drivers/comedi_fc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/comedi_fc.c 
b/drivers/staging/comedi/drivers/comedi_fc.c
index 63be619..8372829 100644
--- a/drivers/staging/comedi/drivers/comedi_fc.c
+++ b/drivers/staging/comedi/drivers/comedi_fc.c
@@ -53,7 +53,7 @@ unsigned int cfc_write_array_to_buffer(struct 
comedi_subdevice *subd,
 
retval = comedi_buf_write_alloc(async, num_bytes);
if (retval != num_bytes) {
-   printk(KERN_WARNING "comedi: buffer overrun\n");
+   dev_warn(subd->device->class_dev, "comedi: buffer overrun\n");
async->events |= COMEDI_CB_OVERFLOW;
return 0;
}
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] staging/comedi: fix the spaces issue around that '->' in drivers/gsc_hpdi.c

2012-11-03 Thread YAMANE Toshiaki
fixed below checkpatch error.
- ERROR: spaces prohibited around that '->' (ctx:VxW)

Signed-off-by: YAMANE Toshiaki 
---
 drivers/staging/comedi/drivers/gsc_hpdi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c 
b/drivers/staging/comedi/drivers/gsc_hpdi.c
index 4809295..3342a46 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -621,7 +621,7 @@ static void hpdi_detach(struct comedi_device *dev)
sizeof(struct plx_dma_desc) *
NUM_DMA_DESCRIPTORS,
devpriv->dma_desc,
-   devpriv-> dma_desc_phys_addr);
+   devpriv->dma_desc_phys_addr);
if (devpriv->hpdi_phys_iobase)
comedi_pci_disable(devpriv->hw_dev);
pci_dev_put(devpriv->hw_dev);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [RFC] Second attempt at kernel secure boot support

2012-11-03 Thread Matthew Garrett
On Sat, Nov 03, 2012 at 12:03:56PM +, James Bottomley wrote:
> On Sat, 2012-11-03 at 00:22 +, Matthew Garrett wrote:
> > Why would an attacker use one of those Linux systems? There's going to 
> > be plenty available that don't have that restriction.
> 
> It's called best practices.  If someone else releases something that
> doesn't conform to them, then it's their signing key in jeopardy, not
> yours.  You surely must see that the goal of securing "everything"
> against "anything" isn't achievable because if someone releases a
> bootloader not conforming to the best practices, why would they have
> bothered to include your secure boot lockdowns in their kernel.  In
> other words, you lost ab initio, so it's pointless to cite this type of
> thing as a rationale for a kernel lockdown patch.

I... what? Our signed bootloader will boot our signed kernel without any 
physically present end-user involvement. We therefore need to make it 
as difficult as practically possible for an attacker to use our signed 
bootloader and our signed kernel as an attack vector against other 
operating systems, which includes worrying about hibernate and kexec. If 
people want to support this use case then patches to deal with that need 
to be present in the upstream kernel.

-- 
Matthew Garrett | mj...@srcf.ucam.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


  1   2   3   >