Re: [alsa-devel] [PATCH 5/5] snd-ice1712: Fix resume on ice1724

2012-10-16 Thread Takashi Iwai
At Sun, 14 Oct 2012 21:09:23 +0200,
Ondrej Zary wrote:
> 
> set_pro_rate() is called from hw_params() but not from prepare(), breaking 
> running PCM on suspend/resume.
> Call it from prepare() if PCM was suspended to fix the problem.
> 
> Signed-off-by: Ondrej Zary 

This should be fixed in the resume callback.  Could you check the
patch below instead?


thanks,

Takashi

---
diff --git a/sound/pci/ice1712/ice1724.c b/sound/pci/ice1712/ice1724.c
index 161c8f6..5cc3fa5 100644
--- a/sound/pci/ice1712/ice1724.c
+++ b/sound/pci/ice1712/ice1724.c
@@ -2867,7 +2867,12 @@ static int snd_vt1724_resume(struct device *dev)
ice->set_spdif_clock(ice, 0);
} else {
/* internal on-card clock */
-   snd_vt1724_set_pro_rate(ice, ice->pro_rate_default, 1);
+   int rate;
+   if (ice->cur_rate)
+   rate = ice->cur_rate;
+   else
+   rate = ice->pro_rate_default;
+   snd_vt1724_set_pro_rate(ice, rate, 1);
}
 
update_spdif_bits(ice, ice->pm_saved_spdif_ctrl);
--
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 v5 12/14] execute the whole memcg freeing in free_worker

2012-10-16 Thread Kamezawa Hiroyuki
(2012/10/16 19:16), Glauber Costa wrote:
> A lot of the initialization we do in mem_cgroup_create() is done with
> softirqs enabled. This include grabbing a css id, which holds
> &ss->id_lock->rlock, and the per-zone trees, which holds
> rtpz->lock->rlock. All of those signal to the lockdep mechanism that
> those locks can be used in SOFTIRQ-ON-W context. This means that the
> freeing of memcg structure must happen in a compatible context,
> otherwise we'll get a deadlock, like the one bellow, caught by lockdep:
> 
>[] free_accounted_pages+0x47/0x4c
>[] free_task+0x31/0x5c
>[] __put_task_struct+0xc2/0xdb
>[] put_task_struct+0x1e/0x22
>[] delayed_put_task_struct+0x7a/0x98
>[] __rcu_process_callbacks+0x269/0x3df
>[] rcu_process_callbacks+0x31/0x5b
>[] __do_softirq+0x122/0x277
> 
> This usage pattern could not be triggered before kmem came into play.
> With the introduction of kmem stack handling, it is possible that we
> call the last mem_cgroup_put() from the task destructor, which is run in
> an rcu callback. Such callbacks are run with softirqs disabled, leading
> to the offensive usage pattern.
> 
> In general, we have little, if any, means to guarantee in which context
> the last memcg_put will happen. The best we can do is test it and try to
> make sure no invalid context releases are happening. But as we add more
> code to memcg, the possible interactions grow in number and expose more
> ways to get context conflicts. One thing to keep in mind, is that part
> of the freeing process is already deferred to a worker, such as vfree(),
> that can only be called from process context.
> 
> For the moment, the only two functions we really need moved away are:
> 
>* free_css_id(), and
>* mem_cgroup_remove_from_trees().
> 
> But because the later accesses per-zone info,
> free_mem_cgroup_per_zone_info() needs to be moved as well. With that, we
> are left with the per_cpu stats only. Better move it all.
> 
> Signed-off-by: Glauber Costa 
> Tested-by: Greg Thelen 
> Acked-by: Michal Hocko 
> CC: KAMEZAWA Hiroyuki 
> CC: Johannes Weiner 
> CC: Tejun Heo 

Acked-by: KAMEZAWA Hiroyuki 


--
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: [alsa-devel] [PATCH 0/5] snd-ice1712: Add Philips PSC724 Ultimate Edge

2012-10-16 Thread Takashi Iwai
At Sun, 14 Oct 2012 21:09:18 +0200,
Ondrej Zary wrote:
> 
> Hello,
> this patch series adds full support for Philips PSC724 Ultimate Edge sound
> card to snd-ice1712 driver. Unlike other snd-ice1712 subdrivers, the codec
> code is splitted into separate files, reusable by other ice1712 subdrivers.
> 
> Working: all analog outputs (front, rear, center+lfe, headphone) and inputs
> (front mic, rear mic, line, cd, aux), mixer, headphone jack detection,
> suspend/resume
> 
> Untested: SPDIF

Applied patches 1-4 now, but skipped 5.  See the reply to the post for
details.


thanks,

Takashi
--
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: ata4.00: failed to get Identify Device Data, Emask 0x1

2012-10-16 Thread Aaron Lu
On 10/17/2012 12:50 PM, Robert Hancock wrote:
> On 10/16/2012 07:38 PM, Aaron Lu wrote:
>> On 10/16/2012 11:18 PM, Borislav Petkov wrote:
>>> On Tue, Oct 16, 2012 at 03:58:24PM +0100, Alan Cox wrote:
 Can you check whether 3.6 works on them. I know 3.6 is horribly broken
 on several brands of AHCI controller (Jmicron for example). Dunno
 where Jeff is on fixing the regressions ?
>>>
>>> If by "works" you mean I don't see the message there, then yes, it does.
>>> Logs say the message started appearing on Oct 4th after me building
>>> Linus master after the merge window started.
>>>
>>> Ok, let me test 3.6.2 just in case .. yes, no error message
>>> there.
>>
>> This is brought by commit: 65fe1f0f66a57380229a4ced844188103135f37b,
>> ahci: implement aggressive SATA device sleep support.
>>
>> Shane, got time to take a look? This debug message made people
>> uncomfortable :-)
> 
> I don't have whatever version of ATA command set defines this command, 
> but surely there's some identify bit which lists whether this log page 
> is supported. Right now checking for it is only conditional on NCQ support.

Agree. If NCQ does not imply support of this log page, we should
definitely refine the check condition used here.

I suppose Shane will take care of this, but if he doesn't, I'll do that
at a later time.

Thanks,
Aaron

--
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: [3.5.0 BUG] vmx_handle_exit: unexpected, valid vectoring info (0x80000b0e)

2012-10-16 Thread Fengguang Wu
On Wed, Oct 17, 2012 at 02:26:22PM +0800, Xiao Guangrong wrote:
> On 09/14/2012 01:57 PM, Xiao Guangrong wrote:
> > On 09/12/2012 04:15 PM, Avi Kivity wrote:
> >> On 09/12/2012 07:40 AM, Fengguang Wu wrote:
> >>> Hi,
> >>>
> >>> 3 of my test boxes running v3.5 kernel become unaccessible and I find
> >>> two of them kept emitting this dmesg:
> >>>
> >>> vmx_handle_exit: unexpected, valid vectoring info (0x8b0e) and exit 
> >>> reason is 0x31
> >>>
> >>> The other one has froze and the above lines are the last dmesg.
> >>> Any ideas?
> >>
> >> First, that printk should be rate-limited.
> >>
> >> Second, we should add EXIT_REASON_EPT_MISCONFIG (0x31) to 
> >>
> >>if ((vectoring_info & VECTORING_INFO_VALID_MASK) &&
> >>(exit_reason != EXIT_REASON_EXCEPTION_NMI &&
> >>exit_reason != EXIT_REASON_EPT_VIOLATION &&
> >>exit_reason != EXIT_REASON_TASK_SWITCH))
> >>printk(KERN_WARNING "%s: unexpected, valid vectoring info "
> >>   "(0x%x) and exit reason is 0x%x\n",
> >>   __func__, vectoring_info, exit_reason);
> >>
> >> since it's easily caused by the guest.
> > 
> > Yes, i will do these.
> > 
> >>
> >> Third, it's really unexpected.  It seems the guest was attempting to 
> >> deliver a page fault exception (0x0e) but encountered an mmio page during 
> >> delivery (in the IDT, TSS, stack, or page tables).  Is this reproducible?  
> >> If so it's easy to patch kvm to halt in that case and allow examining the 
> >> guest via qemu.
> >>
> > 
> > Have no idea yet why the box was frozen under this case, will try to write 
> > a test case,
> > hope it can help me to find the reason out.
> > 
> 
> Still did not know why linux kernel triggered it. I have posted
> a patchset to report an internal error for this case, hoping
> Fengguang can reproduce it after the patchset and Qemu's dump
> can help us to find the reason out.
> 
> I will keep working on it.

Thanks! Shall I run some patched kernel, or just 3.6.0?

Another problem I sometimes run into is, dmesg no longer works in the
test boxes that run lots of KVMs. It aborts with an error message:

dmesg: klogctl failed: Bad address

Thanks,
Fengguang
--
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 1/4] acpi,memory-hotplug : add memory offline code to acpi_memory_device_remove()

2012-10-16 Thread Wen Congyang
At 10/13/2012 03:10 AM, KOSAKI Motohiro Wrote:
 -static int acpi_memory_disable_device(struct acpi_memory_device 
 *mem_device)
 +static int acpi_memory_remove_memory(struct acpi_memory_device 
 *mem_device)
  {
 int result;
 struct acpi_memory_info *info, *n;

 +   list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
>>>
>>> Which lock protect this loop?
>>
>> There is no any lock to protect it now...
> 
> When iterate an item removal list, you should use lock for protecting from
> memory corruption.
> 
> 
> 
> 
 +static int acpi_memory_disable_device(struct acpi_memory_device 
 *mem_device)
 +{
 +   int result;

 /*
  * Ask the VM to offline this memory range.
  * Note: Assume that this function returns zero on success
  */
>>>
>>> Write function comment instead of this silly comment.
>>>
 -   list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
 -   if (info->enabled) {
 -   result = remove_memory(info->start_addr, 
 info->length);
 -   if (result)
 -   return result;
 -   }
 -   kfree(info);
 -   }
 +   result = acpi_memory_remove_memory(mem_device);
 +   if (result)
 +   return result;

 /* Power-off and eject the device */
 result = acpi_memory_powerdown_device(mem_device);
>>>
>>> This patch move acpi_memory_powerdown_device() from 
>>> ACPI_NOTIFY_EJECT_REQUEST
>>> to release callback, but don't explain why.
>>
>> Hmm, it doesn't move the code. It just reuse the code in 
>> acpi_memory_powerdown_device().
> 
> Even if reuse or not reuse, you changed the behavior. If any changes
> has no good rational, you cannot get an ack.

I don't understand this? IIRC, the behavior isn't changed.

Thanks
Wen Congyang

> 
> 
> 
> 
 @@ -473,12 +486,23 @@ static int acpi_memory_device_add(struct
  static int acpi_memory_device_remove(struct acpi_device *device, int type)
  {
 struct acpi_memory_device *mem_device = NULL;
 -
 +   int result;

 if (!device || !acpi_driver_data(device))
 return -EINVAL;

 mem_device = acpi_driver_data(device);
 +
 +   if (type == ACPI_BUS_REMOVAL_EJECT) {
 +   /*
 +* offline and remove memory only when the memory device is
 +* ejected.
 +*/
>>>
>>> This comment explain nothing. A comment should describe _why_ should we do.
>>> e.g. Why REMOVAL_NORMAL and REMOVEL_EJECT should be ignored. Why
>>> we need remove memory here instead of ACPI_NOTIFY_EJECT_REQUEST.
>>
>> Hmm, we have 2 ways to remove a memory:
>> 1. SCI
>> 2. echo 1 >/sys/bus/acpi/devices/PNP0C80:XX/eject
>>
>> In the 2nd case, there is no ACPI_NOTIFY_EJECT_REQUEST. We should offline
>> the memory and remove it from kernel in the release callback. We will 
>> poweroff
>> the memory device in acpi_bus_hot_remove_device(), so we must offline
>> and remove it if the type is ACPI_BUS_REMOVAL_EJECT.
>>
>> I guess we should not poweroff the memory device when we fail to offline it.
>> But device_release_driver() doesn't returns any error...
> 
> 1) I think /sys/bus/acpi/devices/PNP0C80:XX/eject should emulate acpi
> eject. Can't
> you make a pseudo acpi eject event and detach device by acpi regular path?
> 
> 2) Your explanation didn't explain why we should ignore REMOVAL_NORMAL
> and REMOVEL_EJECT. As far as reviewers can't track your intention, we
> can't maintain
> the code and can't ack them.
> 

--
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 v5 06/14] memcg: kmem controller infrastructure

2012-10-16 Thread Kamezawa Hiroyuki
(2012/10/16 19:16), Glauber Costa wrote:
> This patch introduces infrastructure for tracking kernel memory pages to
> a given memcg. This will happen whenever the caller includes the flag
> __GFP_KMEMCG flag, and the task belong to a memcg other than the root.
> 
> In memcontrol.h those functions are wrapped in inline acessors.  The
> idea is to later on, patch those with static branches, so we don't incur
> any overhead when no mem cgroups with limited kmem are being used.
> 
> Users of this functionality shall interact with the memcg core code
> through the following functions:
> 
> memcg_kmem_newpage_charge: will return true if the group can handle the
> allocation. At this point, struct page is not
> yet allocated.
> 
> memcg_kmem_commit_charge: will either revert the charge, if struct page
>allocation failed, or embed memcg information
>into page_cgroup.
> 
> memcg_kmem_uncharge_page: called at free time, will revert the charge.
> 
> [ v2: improved comments and standardized function names ]
> [ v3: handle no longer opaque, functions not exported,
>even more comments ]
> [ v4: reworked Used bit handling and surroundings for more clarity ]
> [ v5: simplified code for kmemcg compiled out and core functions in
>memcontrol.c, moved kmem code to the middle to avoid forward decls ]
> 
> Signed-off-by: Glauber Costa 
> Acked-by: Michal Hocko 
> CC: Christoph Lameter 
> CC: Pekka Enberg 
> CC: Kamezawa Hiroyuki 
> CC: Johannes Weiner 
> CC: Tejun Heo 

Acked-by: KAMEZAWA Hiroyuki 



--
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 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Joe Perches
On Wed, 2012-10-17 at 12:03 +0530, Viresh Kumar wrote:
> On 17 October 2012 11:56, Joe Perches  wrote:
> > Oh good, but please use a space between KBUILD_MODNAME
> > and the quoted ": ".
> 
> Anything technical behind it or just for code formatting?

Just code formatting though it makes it easier to remove all
these unnecessary defines when it becomes the default prefix
some year soon.

cheers, Joe

--
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 V2] extcon : register for cable interest by cable name

2012-10-16 Thread Jenny TC
There are some scnearios where a driver/framework needs to register
interest for a particular cable without specifying the extcon device
name. One such scenario is charger notifications. The platform will
have charger cabel which will be bound to any extcon device. It's
not mandatory for the charger driver to know which extcon device
it should use. This patch enables the support for registering
interest for a cable just by cable name wihtout specifying the
extcon device name

Signed-off-by: Jenny TC 
---
v1:
  Initial submit
V2:
  Removed the new API and modified the extcon_register_interest
  API to accomodate the new requirement

 drivers/extcon/extcon-class.c |   43 +++--
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/drivers/extcon/extcon-class.c b/drivers/extcon/extcon-class.c
index 946a318..738919e 100644
--- a/drivers/extcon/extcon-class.c
+++ b/drivers/extcon/extcon-class.c
@@ -466,22 +466,45 @@ int extcon_register_interest(struct 
extcon_specific_cable_nb *obj,
 const char *extcon_name, const char *cable_name,
 struct notifier_block *nb)
 {
-   if (!obj || !extcon_name || !cable_name || !nb)
+
+   if (!obj || !cable_name || !nb)
return -EINVAL;
 
-   obj->edev = extcon_get_extcon_dev(extcon_name);
-   if (!obj->edev)
-   return -ENODEV;
+   if (extcon_name) {
+
+   obj->edev = extcon_get_extcon_dev(extcon_name);
+   if (!obj->edev)
+   return -ENODEV;
+
+   obj->cable_index = extcon_find_cable_index(obj->edev, 
cable_name);
+   if (obj->cable_index < 0)
+   return -ENODEV;
 
-   obj->cable_index = extcon_find_cable_index(obj->edev, cable_name);
-   if (obj->cable_index < 0)
-   return -ENODEV;
+   obj->user_nb = nb;
 
-   obj->user_nb = nb;
+   obj->internal_nb.notifier_call = _call_per_cable;
 
-   obj->internal_nb.notifier_call = _call_per_cable;
+   return raw_notifier_chain_register(&obj->edev->nh, 
&obj->internal_nb);
+   } else {
+   struct class_dev_iter iter;
+   struct extcon_dev *extd;
+   struct device *dev;
+   if (!extcon_class)
+   return -ENODEV;
+   class_dev_iter_init(&iter, extcon_class, NULL, NULL);
+   while ((dev = class_dev_iter_next(&iter))) {
+   extd = (struct extcon_dev *)dev_get_drvdata(dev);
+
+   if (extcon_find_cable_index(extd, cable_name) < 0)
+   continue;
+
+   class_dev_iter_exit(&iter);
+   return extcon_register_interest(obj, extd->name,
+   cable_name, nb);
+   }
 
-   return raw_notifier_chain_register(&obj->edev->nh, &obj->internal_nb);
+   return -ENODEV;
+   }
 }
 
 /**
-- 
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: [PATCH] CAN: sja1000: Add support for Connect Tech Inc's Canpro/104-Plus Opto CAN board

2012-10-16 Thread Wolfgang Grandegger
On 10/16/2012 11:03 PM, Muhammad Ghias wrote:
> Patch adds support for CANpro/104-Plus Opto CAN board. Board uses PLX9030
> bridge and two NXP SJA1000 CAN controllers. Patch is generated and tested
> with kernel 3.6.1.
> 
> If you have any questions or any feedback please let me know.
> 
> Thanks,

The above two lines should go ...

> Signed-off-by: Muhammad Ghias 
> ---

... here (out of the commit message).

Apart from that the patch looks good. You can add my

Acked-by: Wolfgang Grandegger 

Thanks for your contribution.

Wolfgang.

--
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] extcon : callback function to read cable property

2012-10-16 Thread Tc, Jenny
Myunjoo/Chanwoo

Ping...
Could you please review this patch?

-jtc

> > > Subject: Re: [PATCH] extcon : callback function to read cable
> > > property
> > >
> > > I think the reason why we have extcon is in first place is to only
> > > notify the clients of cable connection and disconnection and it is
> > > up to the client to decide what else to do with the cable such as
> > > finding which state it is in and other details.
> > > So I feel this should not be handled in the extcon.
> > >
> > > However it is up to the maintainer to decide.
> >
> > Once the consumer gets the notification, it needs to take some action.
> > One of the action is to read the cable properties. This can be done by
> > proprietary calls which is known both to the consumer and the provider.
> > My intention is to avoid this proprietary calls. Since both the
> > provider and consumer are communicating with the extcon subsystem , I
> > feel having a callback function of this kind would help to avoid the
> > use of proprietary calls. Also I agree that extcon notifier chains are
> > used to notify the cable state (attach/detach). But if a cable has
> > more than two states (like the charger cable) how do we support it without
> having a callback function like this?
> > Let the maintainer take the final decision.
> Well this use case will keep on growing if we start factor in this kind of
> changes and that is why I am opposed to adding any other state.
> Maintainer?
> >
> >
> 



Re: [RFC v3 09/13] vfs: add one wq to update map info periodically

2012-10-16 Thread Zhi Yong Wu
On Tue, Oct 16, 2012 at 8:27 AM, Dave Chinner  wrote:
> On Wed, Oct 10, 2012 at 06:07:31PM +0800, zwu.ker...@gmail.com wrote:
>> From: Zhi Yong Wu 
>>
>>   Add a per-superblock workqueue and a work_struct
>>  to run periodic work to update map info on each superblock.
>>
>> Signed-off-by: Zhi Yong Wu 
>> ---
>>  fs/hot_tracking.c|   94 
>> ++
>>  fs/hot_tracking.h|3 +
>>  include/linux/hot_tracking.h |2 +
>>  3 files changed, 99 insertions(+), 0 deletions(-)
>>
>> diff --git a/fs/hot_tracking.c b/fs/hot_tracking.c
>> index a8dc599..f333c47 100644
>> --- a/fs/hot_tracking.c
>> +++ b/fs/hot_tracking.c
>> @@ -15,6 +15,8 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -623,6 +625,88 @@ static void hot_map_array_exit(struct hot_info *root)
>>  }
>>
>>  /*
>> + * Update temperatures for each hot inode item and
>> + * hot range item for aging purposes
>> + */
>> +static void hot_temperature_update_work(struct work_struct *work)
>> +{
>> + struct hot_update_work *hot_work =
>> + container_of(work, struct hot_update_work, work);
>> + struct hot_info *root = hot_work->hot_info;
>> + struct hot_inode_item *hi_nodes[8];
>> + unsigned long delay = HZ * HEAT_UPDATE_DELAY;
>> + u64 ino = 0;
>> + int i, n;
>> +
>> + do {
>> + while (1) {
>> + spin_lock(&root->lock);
>> + n = radix_tree_gang_lookup(&root->hot_inode_tree,
>> +(void **)hi_nodes, ino,
>> +ARRAY_SIZE(hi_nodes));
>> + if (!n) {
>> + spin_unlock(&root->lock);
>> + break;
>> + }
>> +
>> + ino = hi_nodes[n - 1]->i_ino + 1;
>> + for (i = 0; i < n; i++) {
>> + kref_get(&hi_nodes[i]->hot_inode.refs);
>> + hot_map_array_update(
>> + &hi_nodes[i]->hot_inode.hot_freq_data, 
>> root);
>> + hot_range_update(hi_nodes[i], root);
>> + hot_inode_item_put(hi_nodes[i]);
>> + }
>> + spin_unlock(&root->lock);
>
> This is a lot of work to do under a spin lock. Perhaps you should
> get a reference on all the nodes, then drop the root->lock and then
> update all the nodes in a separate loop.
OK, done
>
>> + }
>> +
>> + if (unlikely(freezing(current))) {
>> + __refrigerator(true);
>> + } else {
>> + set_current_state(TASK_INTERRUPTIBLE);
>> + if (!kthread_should_stop()) {
>> + schedule_timeout(delay);
>> + }
>> + __set_current_state(TASK_RUNNING);
>> + }
>> + } while (!kthread_should_stop());
>
> I don't think you understand workqueues fully. A work queue worker
> function is not something that executes endlessly. It is a
> "one-shot" function that does the work once, not an endless loop
> that has to delay it's execution for periodic work.
ah, i have done this based on your following suggestions, thanks.
>
> If you need periodic work, then you should use a struct delayed_work
> and queue the next work iteration to be run a later time. See, for
> example, xfs_syncd_worker() and xfs_syncd_queue_sync() and how that
> reschedules itself for periodic work. It also means you don't have
> to handle kthread freezing, as the WQ infrastructure takes care of
> that for you.
ditto.
>
> This is why unmount is hanging for me - this work never completes,
> so flush_workqueue() will never return.
got it, thanks.
>
>> +}
>> +
>> +static int hot_wq_init(struct hot_info *root)
>> +{
>> + struct hot_update_work *hot_work;
>> + int ret = 0;
>> +
>> + root->update_wq = alloc_workqueue(
>> + "hot_temperature_update", WQ_MEM_RECLAIM | WQ_UNBOUND, 1);
>> + if (!root->update_wq) {
>> + printk(KERN_ERR "%s: failed to create "
>> + "temperature update workqueue\n",
>> + __func__);
>> + return 1;
>> + }
>> +
>> + hot_work = kmalloc(sizeof(*hot_work), GFP_NOFS);
>> + if (hot_work) {
>> + hot_work->hot_info = root;
>> + INIT_WORK(&hot_work->work, hot_temperature_update_work);
>> + queue_work(root->update_wq, &hot_work->work);
>> + } else {
>> + printk(KERN_ERR "%s: failed to create update work\n",
>> + __func__);
>> + ret = 1;
>> + }
>
> I don't understand why you need a separate "hot_work" structure.
> just embed a struct delayed_work in the struct hot_info and use
> container_of() to get the struct hot

Re: [PATCH 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Viresh Kumar
On 17 October 2012 11:56, Joe Perches  wrote:
> Oh good, but please use a space between KBUILD_MODNAME
> and the quoted ": ".

Anything technical behind it or just for code formatting? As output is
same in both cases :)

8<--8<---

From: Viresh Kumar 
Date: Wed, 17 Oct 2012 10:38:31 +0530
Subject: [PATCH] cpufreq: Improve debug prints

With debug options on, it is difficult to locate cpufreq core's debug prints.
Fix this by prefixing debug prints with KBUILD_MODNAME.

Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/cpufreq.c | 2 ++
 drivers/cpufreq/cpufreq_performance.c | 2 ++
 drivers/cpufreq/cpufreq_powersave.c   | 2 ++
 drivers/cpufreq/cpufreq_userspace.c   | 2 ++
 drivers/cpufreq/freq_table.c  | 2 ++
 5 files changed, 10 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index db6e337..85df538 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -15,6 +15,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_performance.c
b/drivers/cpufreq/cpufreq_performance.c
index f13a8a9..ceee068 100644
--- a/drivers/cpufreq/cpufreq_performance.c
+++ b/drivers/cpufreq/cpufreq_performance.c
@@ -10,6 +10,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_powersave.c
b/drivers/cpufreq/cpufreq_powersave.c
index 4c2eb51..2d948a1 100644
--- a/drivers/cpufreq/cpufreq_powersave.c
+++ b/drivers/cpufreq/cpufreq_powersave.c
@@ -10,6 +10,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_userspace.c
b/drivers/cpufreq/cpufreq_userspace.c
index bedac1a..c8c3d29 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -11,6 +11,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 90431cb..49cda25 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -9,6 +9,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include 
 #include 
 #include 
--
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] qla3xxx: Ensure req_q_phy_addr writes to the register

2012-10-16 Thread Joe Jin
Make sure req_q_phy_addr write to the register.

Signed-off-by: Joe Jin 
Cc: Ron Mercer 
Cc: Jitendra Kalsaria 
---
 drivers/net/ethernet/qlogic/qla3xxx.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c 
b/drivers/net/ethernet/qlogic/qla3xxx.c
index df09b1c..78b4cba 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -2525,6 +2525,12 @@ static int ql_alloc_net_req_rsp_queues(struct 
ql3_adapter *qdev)
qdev->req_q_size =
(u32) (NUM_REQ_Q_ENTRIES * sizeof(struct ob_mac_iocb_req));
 
+   /*
+* The barrier is required to ensure that req_q_phy_addr writes to
+* the memory.
+*/
+   wmb();
+
qdev->req_q_virt_addr =
pci_alloc_consistent(qdev->pdev,
 (size_t) qdev->req_q_size,
-- 
1.7.11.7



Re: [PATCH 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Joe Perches
On Wed, 2012-10-17 at 11:47 +0530, Viresh Kumar wrote:
> On 17 October 2012 11:34, Joe Perches  wrote:
> > I believe you are quoting KBUILD_MODNAME
> 
> Yes. :(
> Far better output with this. Thanks.

Oh good, but please use a space between KBUILD_MODNAME
and the quoted ": ".

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

look at:
$ git grep -E -h "pr_fmt.*KBUILD_MODNAME" *|sort|uniq -c|sort -rn


--
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: [3.5.0 BUG] vmx_handle_exit: unexpected, valid vectoring info (0x80000b0e)

2012-10-16 Thread Xiao Guangrong
On 09/14/2012 01:57 PM, Xiao Guangrong wrote:
> On 09/12/2012 04:15 PM, Avi Kivity wrote:
>> On 09/12/2012 07:40 AM, Fengguang Wu wrote:
>>> Hi,
>>>
>>> 3 of my test boxes running v3.5 kernel become unaccessible and I find
>>> two of them kept emitting this dmesg:
>>>
>>> vmx_handle_exit: unexpected, valid vectoring info (0x8b0e) and exit 
>>> reason is 0x31
>>>
>>> The other one has froze and the above lines are the last dmesg.
>>> Any ideas?
>>
>> First, that printk should be rate-limited.
>>
>> Second, we should add EXIT_REASON_EPT_MISCONFIG (0x31) to 
>>
>>  if ((vectoring_info & VECTORING_INFO_VALID_MASK) &&
>>  (exit_reason != EXIT_REASON_EXCEPTION_NMI &&
>>  exit_reason != EXIT_REASON_EPT_VIOLATION &&
>>  exit_reason != EXIT_REASON_TASK_SWITCH))
>>  printk(KERN_WARNING "%s: unexpected, valid vectoring info "
>> "(0x%x) and exit reason is 0x%x\n",
>> __func__, vectoring_info, exit_reason);
>>
>> since it's easily caused by the guest.
> 
> Yes, i will do these.
> 
>>
>> Third, it's really unexpected.  It seems the guest was attempting to deliver 
>> a page fault exception (0x0e) but encountered an mmio page during delivery 
>> (in the IDT, TSS, stack, or page tables).  Is this reproducible?  If so it's 
>> easy to patch kvm to halt in that case and allow examining the guest via 
>> qemu.
>>
> 
> Have no idea yet why the box was frozen under this case, will try to write a 
> test case,
> hope it can help me to find the reason out.
> 

Still did not know why linux kernel triggered it. I have posted
a patchset to report an internal error for this case, hoping
Fengguang can reproduce it after the patchset and Qemu's dump
can help us to find the reason out.

I will keep working on it.


--
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 v5 1/2] x86, pci: Reset PCIe devices at boot time

2012-10-16 Thread Takao Indoh
This patch resets PCIe devices at boot time by hot reset when
"reset_devices" is specified.

Signed-off-by: Takao Indoh 
---
 arch/x86/include/asm/pci-direct.h |1 
 arch/x86/kernel/setup.c   |3 
 arch/x86/pci/early.c  |  353 
 include/linux/pci.h   |2 
 init/main.c   |4 
 5 files changed, 361 insertions(+), 2 deletions(-)

diff --git a/arch/x86/include/asm/pci-direct.h 
b/arch/x86/include/asm/pci-direct.h
index b1e7a45..de30db2 100644
--- a/arch/x86/include/asm/pci-direct.h
+++ b/arch/x86/include/asm/pci-direct.h
@@ -18,4 +18,5 @@ extern int early_pci_allowed(void);
 extern unsigned int pci_early_dump_regs;
 extern void early_dump_pci_device(u8 bus, u8 slot, u8 func);
 extern void early_dump_pci_devices(void);
+extern void early_reset_pcie_devices(void);
 #endif /* _ASM_X86_PCI_DIRECT_H */
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
index a2bb18e..73d3425 100644
--- a/arch/x86/kernel/setup.c
+++ b/arch/x86/kernel/setup.c
@@ -987,6 +987,9 @@ void __init setup_arch(char **cmdline_p)
generic_apic_probe();
 
early_quirks();
+#ifdef CONFIG_PCI
+   early_reset_pcie_devices();
+#endif
 
/*
 * Read APIC and some other early information from ACPI tables.
diff --git a/arch/x86/pci/early.c b/arch/x86/pci/early.c
index d1067d5..df7f4fc 100644
--- a/arch/x86/pci/early.c
+++ b/arch/x86/pci/early.c
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -109,3 +110,355 @@ void early_dump_pci_devices(void)
}
}
 }
+
+#define PCI_EXP_SAVE_REGS  7
+#define pcie_cap_has_devctl(type, flags)   1
+#define pcie_cap_has_lnkctl(type, flags)   \
+   ((flags & PCI_EXP_FLAGS_VERS) > 1 ||\
+(type == PCI_EXP_TYPE_ROOT_PORT || \
+ type == PCI_EXP_TYPE_ENDPOINT ||  \
+ type == PCI_EXP_TYPE_LEG_END))
+#define pcie_cap_has_sltctl(type, flags)   \
+   ((flags & PCI_EXP_FLAGS_VERS) > 1 ||\
+((type == PCI_EXP_TYPE_ROOT_PORT) ||   \
+ (type == PCI_EXP_TYPE_DOWNSTREAM &&   \
+  (flags & PCI_EXP_FLAGS_SLOT
+#define pcie_cap_has_rtctl(type, flags)\
+   ((flags & PCI_EXP_FLAGS_VERS) > 1 ||\
+(type == PCI_EXP_TYPE_ROOT_PORT || \
+ type == PCI_EXP_TYPE_RC_EC))
+
+struct save_config {
+   u32 pci[16];
+   u16 pcie[PCI_EXP_SAVE_REGS];
+};
+
+struct pcie_dev {
+   int cap;   /* position of PCI Express capability */
+   int flags; /* PCI_EXP_FLAGS */
+   struct save_config save; /* saved configration register */
+};
+
+struct pcie_port {
+   struct list_head dev;
+   u8 bus;
+   u8 slot;
+   u8 func;
+   u8 secondary;
+   struct pcie_dev child[PCI_MAX_FUNCTIONS];
+};
+
+static LIST_HEAD(device_list);
+static void __init pci_udelay(int loops)
+{
+   while (loops--) {
+   /* Approximately 1 us */
+   native_io_delay();
+   }
+}
+
+/* Derived from drivers/pci/pci.c */
+#define PCI_FIND_CAP_TTL   48
+static int __init __pci_find_next_cap_ttl(u8 bus, u8 slot, u8 func,
+ u8 pos, int cap, int *ttl)
+{
+   u8 id;
+
+   while ((*ttl)--) {
+   pos = read_pci_config_byte(bus, slot, func, pos);
+   if (pos < 0x40)
+   break;
+   pos &= ~3;
+   id = read_pci_config_byte(bus, slot, func,
+   pos + PCI_CAP_LIST_ID);
+   if (id == 0xff)
+   break;
+   if (id == cap)
+   return pos;
+   pos += PCI_CAP_LIST_NEXT;
+   }
+   return 0;
+}
+
+static int __init __pci_find_next_cap(u8 bus, u8 slot, u8 func, u8 pos, int 
cap)
+{
+   int ttl = PCI_FIND_CAP_TTL;
+
+   return __pci_find_next_cap_ttl(bus, slot, func, pos, cap, &ttl);
+}
+
+static int __init __pci_bus_find_cap_start(u8 bus, u8 slot, u8 func,
+  u8 hdr_type)
+{
+   u16 status;
+
+   status = read_pci_config_16(bus, slot, func, PCI_STATUS);
+   if (!(status & PCI_STATUS_CAP_LIST))
+   return 0;
+
+   switch (hdr_type) {
+   case PCI_HEADER_TYPE_NORMAL:
+   case PCI_HEADER_TYPE_BRIDGE:
+   return PCI_CAPABILITY_LIST;
+   case PCI_HEADER_TYPE_CARDBUS:
+   return PCI_CB_CAPABILITY_LIST;
+   default:
+   return 0;
+   }
+
+   return 0;
+}
+
+static int __init early_pci_find_capability(u8 bus, u8 slot, u8 func, int cap)
+{
+   int pos;
+   u8 type = read_pci_config_byte(bus, slot, func, PCI_HEADER_TYPE);
+
+   pos = __pci_bus_find_cap_start(bus, slot, func, type & 0x7f);
+   if (pos)
+   pos = __pci_find_next_

[PATCH v5 2/2] x86, pci: Enable PCI INTx when MSI is disabled

2012-10-16 Thread Takao Indoh
This patch enables INTx if MSI is disabled in pcibios_enable_device().
In normal case interrupt disable bit in command register is 0b on boot
time, but in case of kdump, this bit may be 1b. It causes problems of
some drivers. At leaset I confirmed mptsas driver does not work in such
a case. This patch fix this problem.

Signed-off-by: Takao Indoh 
---
 arch/x86/pci/common.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c
index 720e973..2bb7ecc 100644
--- a/arch/x86/pci/common.c
+++ b/arch/x86/pci/common.c
@@ -615,8 +615,10 @@ int pcibios_enable_device(struct pci_dev *dev, int mask)
if ((err = pci_enable_resources(dev, mask)) < 0)
return err;
 
-   if (!pci_dev_msi_enabled(dev))
+   if (!pci_dev_msi_enabled(dev)) {
+   pci_intx(dev, true);
return pcibios_enable_irq(dev);
+   }
return 0;
 }
 

--
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 v5 0/2] Reset PCIe devices to address DMA problem on kdump with iommu

2012-10-16 Thread Takao Indoh
These patches reset PCIe devices at boot time to address DMA problem on
kdump with iommu. When "reset_devices" is specified, a hot reset is
triggered on each PCIe root port and downstream port to reset its
downstream endpoint.

Background:
A kdump problem about DMA has been discussed for a long time. That is,
when a kernel is switched to the kdump kernel DMA derived from first
kernel affects second kernel. Recently this problem surfaces when iommu
is used for PCI passthrough on KVM guest. In the case of the machine I
use, when intel_iommu=on is specified, DMAR error is detected in kdump
kernel and PCI SERR is also detected. Finally kdump fails because some
devices does not work correctly.

The root cause is that ongoing DMA from first kernel causes DMAR fault
because page table of DMAR is initialized while kdump kernel is booting
up. Therefore to address this problem DMA needs to be stopped before
DMAR is initialized at kdump kernel boot time. By these patches, PCIe
devices are reset by hot reset and its DMA is stopped when reset_devices
is specified. One problem of this solution is that the monitor blacks
out when VGA controller is reset. So this patch does not reset the port
whose child endpoint is VGA device.

What I tried:
- Clearing bus master bit and INTx disable bit at boot time
This did not solve this problem. I still got DMAR error on devices.
- Resetting devices in fixup_final(v1 patch)
DMAR error disappeared, but sometimes PCI SERR was detected. This
is well explained here.
https://lkml.org/lkml/2012/9/9/245
This PCI SERR seems to be related to interrupt remapping.
- Clearing bus master in setup_arch() and resetting devices in
  fixup_final
Neither DMAR error nor PCI SERR occurred. But on certain machine
kdump kernel hung up when resetting devices. It seems to be a
problem specific to the platform.
- Resetting devices in setup_arch() (v2 and later patch)
This solution solves all problems I found so far.

v5:
Do bus reset after all devices are scanned and its config registers are
saved. This fixes a bug that config register is accessed without delay
after reset.

v4:
Reduce waiting time after resetting devices. A previous patch does reset
like this:
  for (each device) {
save config registers
reset
wait for 500 ms
restore config registers
  }

If there are N devices to be reset, it takes N*500 ms. On the other
hand, the v4 patch does:
  for (each device) {
save config registers
reset
  }
  wait 500 ms
  for (each device) {
restore config registers
  }
Though it needs more memory space to save config registers, the waiting
time is always 500ms.
https://lkml.org/lkml/2012/10/15/49

v3:
Move alloc_bootmem and free_bootmem to early_reset_pcie_devices so that
they are called only once.
https://lkml.org/lkml/2012/10/10/57

v2:
Reset devices in setup_arch() because reset need to be done before
interrupt remapping is initialized.
https://lkml.org/lkml/2012/10/2/54

v1:
Add fixup_final quirk to reset PCIe devices
https://lkml.org/lkml/2012/8/3/160

Thanks,
Takao Indoh

--
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] pinctrl: tegra: correct bank for pingroup and drv pingroup

2012-10-16 Thread Pritesh Raithatha
Signed-off-by: Pritesh Raithatha 
---
 drivers/pinctrl/pinctrl-tegra30.c |   24 
 1 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/pinctrl/pinctrl-tegra30.c 
b/drivers/pinctrl/pinctrl-tegra30.c
index 0386fdf..7894f14 100644
--- a/drivers/pinctrl/pinctrl-tegra30.c
+++ b/drivers/pinctrl/pinctrl-tegra30.c
@@ -3345,10 +3345,10 @@ static const struct tegra_function tegra30_functions[] 
= {
FUNCTION(vi_alt3),
 };
 
-#define MUXCTL_REG_A   0x3000
-#define PINGROUP_REG_A 0x868
+#define DRV_PINGROUP_REG_A 0x868   /* bank 0 */
+#define PINGROUP_REG_A 0x3000  /* bank 1 */
 
-#define PINGROUP_REG_Y(r) ((r) - MUXCTL_REG_A)
+#define PINGROUP_REG_Y(r) ((r) - PINGROUP_REG_A)
 #define PINGROUP_REG_N(r) -1
 
 #define PINGROUP(pg_name, f0, f1, f2, f3, f_safe, r, od, ior)  \
@@ -3364,25 +3364,25 @@ static const struct tegra_function tegra30_functions[] 
= {
},  \
.func_safe = TEGRA_MUX_ ## f_safe,  \
.mux_reg = PINGROUP_REG_Y(r),   \
-   .mux_bank = 0,  \
+   .mux_bank = 1,  \
.mux_bit = 0,   \
.pupd_reg = PINGROUP_REG_Y(r),  \
-   .pupd_bank = 0, \
+   .pupd_bank = 1, \
.pupd_bit = 2,  \
.tri_reg = PINGROUP_REG_Y(r),   \
-   .tri_bank = 0,  \
+   .tri_bank = 1,  \
.tri_bit = 4,   \
.einput_reg = PINGROUP_REG_Y(r),\
-   .einput_bank = 0,   \
+   .einput_bank = 1,   \
.einput_bit = 5,\
.odrain_reg = PINGROUP_REG_##od(r), \
-   .odrain_bank = 0,   \
+   .odrain_bank = 1,   \
.odrain_bit = 6,\
.lock_reg = PINGROUP_REG_Y(r),  \
-   .lock_bank = 0, \
+   .lock_bank = 1, \
.lock_bit = 7,  \
.ioreset_reg = PINGROUP_REG_##ior(r),   \
-   .ioreset_bank = 0,  \
+   .ioreset_bank = 1,  \
.ioreset_bit = 8,   \
.drv_reg = -1,  \
}
@@ -3401,8 +3401,8 @@ static const struct tegra_function tegra30_functions[] = {
.odrain_reg = -1,   \
.lock_reg = -1, \
.ioreset_reg = -1,  \
-   .drv_reg = ((r) - PINGROUP_REG_A),  \
-   .drv_bank = 1,  \
+   .drv_reg = ((r) - DRV_PINGROUP_REG_A),  \
+   .drv_bank = 0,  \
.hsm_bit = hsm_b,   \
.schmitt_bit = schmitt_b,   \
.lpmd_bit = lpmd_b, \
-- 
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/


[PATCH] MFD: SEC: Fix reg_offset for interrupt registers

2012-10-16 Thread Inderpal Singh
reg_offset is offset of the status/mask registers. Now, since status_base
and mask_base are pointing to corresponding first registers, reg_offset
should start from 0 otheriwse regmap_add_irq_chip will fail during probe.

Signed-off-by: Inderpal Singh 
---
It is based on Samuel's for-next-merge branch of mfd-2.6 tree. 

 drivers/mfd/sec-irq.c |  102 -
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/drivers/mfd/sec-irq.c b/drivers/mfd/sec-irq.c
index c901fa5..0dd84e9 100644
--- a/drivers/mfd/sec-irq.c
+++ b/drivers/mfd/sec-irq.c
@@ -24,67 +24,67 @@
 
 static struct regmap_irq s2mps11_irqs[] = {
[S2MPS11_IRQ_PWRONF] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_PWRONF_MASK,
},
[S2MPS11_IRQ_PWRONR] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_PWRONR_MASK,
},
[S2MPS11_IRQ_JIGONBF] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_JIGONBF_MASK,
},
[S2MPS11_IRQ_JIGONBR] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_JIGONBR_MASK,
},
[S2MPS11_IRQ_ACOKBF] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_ACOKBF_MASK,
},
[S2MPS11_IRQ_ACOKBR] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_ACOKBR_MASK,
},
[S2MPS11_IRQ_PWRON1S] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_PWRON1S_MASK,
},
[S2MPS11_IRQ_MRB] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S2MPS11_IRQ_MRB_MASK,
},
[S2MPS11_IRQ_RTC60S] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S2MPS11_IRQ_RTC60S_MASK,
},
[S2MPS11_IRQ_RTCA1] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S2MPS11_IRQ_RTCA1_MASK,
},
[S2MPS11_IRQ_RTCA2] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S2MPS11_IRQ_RTCA2_MASK,
},
[S2MPS11_IRQ_SMPL] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S2MPS11_IRQ_SMPL_MASK,
},
[S2MPS11_IRQ_RTC1S] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S2MPS11_IRQ_RTC1S_MASK,
},
[S2MPS11_IRQ_WTSR] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S2MPS11_IRQ_WTSR_MASK,
},
[S2MPS11_IRQ_INT120C] = {
-   .reg_offset = 3,
+   .reg_offset = 2,
.mask = S2MPS11_IRQ_INT120C_MASK,
},
[S2MPS11_IRQ_INT140C] = {
-   .reg_offset = 3,
+   .reg_offset = 2,
.mask = S2MPS11_IRQ_INT140C_MASK,
},
 };
@@ -92,146 +92,146 @@ static struct regmap_irq s2mps11_irqs[] = {
 
 static struct regmap_irq s5m8767_irqs[] = {
[S5M8767_IRQ_PWRR] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_PWRR_MASK,
},
[S5M8767_IRQ_PWRF] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_PWRF_MASK,
},
[S5M8767_IRQ_PWR1S] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_PWR1S_MASK,
},
[S5M8767_IRQ_JIGR] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_JIGR_MASK,
},
[S5M8767_IRQ_JIGF] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_JIGF_MASK,
},
[S5M8767_IRQ_LOWBAT2] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_LOWBAT2_MASK,
},
[S5M8767_IRQ_LOWBAT1] = {
-   .reg_offset = 1,
+   .reg_offset = 0,
.mask = S5M8767_IRQ_LOWBAT1_MASK,
},
[S5M8767_IRQ_MRB] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S5M8767_IRQ_MRB_MASK,
},
[S5M8767_IRQ_DVSOK2] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S5M8767_IRQ_DVSOK2_MASK,
},
[S5M8767_IRQ_DVSOK3] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
.mask = S5M8767_IRQ_DVSOK3_MASK,
},
[S5M8767_IRQ_DVSOK4] = {
-   .reg_offset = 2,
+   .reg_offset = 1,
  

Re: [PATCH 2/2]suppress "Device nodeX does not have a release() function" warning

2012-10-16 Thread Wen Congyang
At 10/12/2012 06:33 AM, KOSAKI Motohiro Wrote:
> On Thu, Oct 11, 2012 at 1:26 AM, Yasuaki Ishimatsu
>  wrote:
>> When calling unregister_node(), the function shows following message at
>> device_release().
>>
>> "Device 'node2' does not have a release() function, it is broken and must
>> be fixed."
>>
>> The reason is node's device struct does not have a release() function.
>>
>> So the patch registers node_device_release() to the device's release()
>> function for suppressing the warning message. Additionally, the patch adds
>> memset() to initialize a node struct into register_node(). Because the node
>> struct is part of node_devices[] array and it cannot be freed by
>> node_device_release(). So if system reuses the node struct, it has a garbage.
>>
>> CC: David Rientjes 
>> CC: Jiang Liu 
>> Cc: Minchan Kim 
>> CC: Andrew Morton 
>> CC: KOSAKI Motohiro 
>> Signed-off-by: Yasuaki Ishimatsu 
>> Signed-off-by: Wen Congyang 
>> ---
>>  drivers/base/node.c |   11 +++
>>  1 file changed, 11 insertions(+)
>>
>> Index: linux-3.6/drivers/base/node.c
>> ===
>> --- linux-3.6.orig/drivers/base/node.c  2012-10-11 10:04:02.149758748 +0900
>> +++ linux-3.6/drivers/base/node.c   2012-10-11 10:20:34.111806931 +0900
>> @@ -252,6 +252,14 @@ static inline void hugetlb_register_node
>>  static inline void hugetlb_unregister_node(struct node *node) {}
>>  #endif
>>
>> +static void node_device_release(struct device *dev)
>> +{
>> +#if defined(CONFIG_MEMORY_HOTPLUG_SPARSE) && defined(CONFIG_HUGETLBFS)
>> +   struct node *node_dev = to_node(dev);
>> +
>> +   flush_work(&node_dev->node_work);
>> +#endif
>> +}
> 
> The patch description don't explain why this flush_work() is needed.

If the node is onlined after it is offlined, we will clear the memory,
so we should flush_work() before node_dev is set to 0.

Thanks
Wen Congyang

> 
> 
>>  /*
>>   * register_node - Setup a sysfs device for a node.
>> @@ -263,8 +271,11 @@ int register_node(struct node *node, int
>>  {
>> int error;
>>
>> +   memset(node, 0, sizeof(*node));
>> +
> 
> You should add a comment why we need initialize a node here. A lot
> of developers don't have hotplug knowledge.
> 

--
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 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Viresh Kumar
On 17 October 2012 11:34, Joe Perches  wrote:
> I believe you are quoting KBUILD_MODNAME

Yes. :(
Far better output with this. Thanks.

@Rafael: Please consider below patch instead:

From: Viresh Kumar 
Date: Wed, 17 Oct 2012 10:38:31 +0530
Subject: [PATCH] cpufreq: Improve debug prints

With debug options on, it is difficult to locate cpufreq core's debug prints.
Fix this by prefixing debug prints with KBUILD_MODNAME.

Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/cpufreq.c | 2 ++
 drivers/cpufreq/cpufreq_performance.c | 2 ++
 drivers/cpufreq/cpufreq_powersave.c   | 2 ++
 drivers/cpufreq/cpufreq_userspace.c   | 2 ++
 drivers/cpufreq/freq_table.c  | 2 ++
 5 files changed, 10 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index db6e337..0504b8b 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -15,6 +15,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_performance.c
b/drivers/cpufreq/cpufreq_performance.c
index f13a8a9..57951dc 100644
--- a/drivers/cpufreq/cpufreq_performance.c
+++ b/drivers/cpufreq/cpufreq_performance.c
@@ -10,6 +10,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_powersave.c
b/drivers/cpufreq/cpufreq_powersave.c
index 4c2eb51..c4540cf 100644
--- a/drivers/cpufreq/cpufreq_powersave.c
+++ b/drivers/cpufreq/cpufreq_powersave.c
@@ -10,6 +10,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_userspace.c
b/drivers/cpufreq/cpufreq_userspace.c
index bedac1a..c0eb546 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -11,6 +11,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME": " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 90431cb..8bcc930 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -9,6 +9,8 @@
  *
  */

+#define pr_fmt(fmt) KBUILD_MODNAME": " fmt
+
 #include 
 #include 
 #include 
--
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/


discrepancy while save and restore of debounce registers

2012-10-16 Thread Hebbar, Gururaja
Hi,

I came across a peculiar issue while updating GPIO debounce registers on
OMAP platform.

According to mainline commit ae547354a8ed59f19b57f7e1de9c7816edfc3537

gpio/omap: save and restore debounce registers

GPIO debounce registers need to be saved and restored for proper functioning
of driver.

...
@@ -1363,6 +1369,12 @@ static void omap_gpio_restore_context(struct gpio_bank 
*bank)
__raw_writel(bank->context.fallingdetect,
bank->base + bank->regs->fallingdetect);
__raw_writel(bank->context.dataout, bank->base + bank->regs->dataout);
+   if (bank->dbck_enable_mask) {
+   __raw_writel(bank->context.debounce, bank->base +
+   bank->regs->debounce);
+   __raw_writel(bank->context.debounce_en,
+   bank->base + bank->regs->debounce_en);
+   }
 }


Due to copy/paste of this commit into my local tree, I missed the check for 
bank->dbck_enable_mask, and directly restored the saved value from context.

After this, I saw random crashes when accessing different registers (sometimes
its OE register and sometime its DATAOUT register). 

These crashes were seen across 2nd and subsequent suspend/resume.

My doubt/questions are
1. Why should debounce registers be updated only when it's accessed previously?

2. What is the relation between updating debounce registers and crash seen on
others registers? 

Thanks in advance for the support.

Regards
Gururaja




Re: [RFC][CFT][CFReview] execve and kernel_thread unification work

2012-10-16 Thread Greg Ungerer

Hi Al,

On 15/10/12 11:30, Al Viro wrote:

On Mon, Oct 01, 2012 at 10:38:09PM +0100, Al Viro wrote:

[with apologies for folks Cc'd, resent due to mis-autoexpanded l-k address
on the original posting ;-/  Mea culpa...]

There's an interesting ongoing project around kernel_thread() and
friends, including execve() variants.  I really need help from architecture
maintainers on that one; I'd been able to handle (and test) quite a few
architectures on my own [alpha, arm, m68k, powerpc, s390, sparc, x86, um]
plus two more untested [frv, mn10300].  c6x patches had been supplied by
Mark Salter; everything else remains to be done.  Right now it's at
minus 1.2KLoC, quite a bit of that removed from asm glue and other black magic.


Update:
* all infrastructure is in mainline now, along with conversion for
kernel_thread() callbacks to the form that allows really simple model for
kernel_execve() _without_ flagday changes.
* #experimental-kernel_thread is gone; this stuff is in for-next
now.
* a lot of architecture conversions had been done and some are
even tested.  Currently missing are only 7 - avr32, hexagon, m32r, openrisc,
score, tile and xtensa.  OTOH, a lot are completely untested.  I've put
per-architecture stuff into separate branches and I promise never rebase
those once arch maintainers will be OK with the stuff in them.  IOW, they'll
be safe to pull into respective architecture trees.

Folks, *please* review the stuff in signal.git#arch-*.  All of them are
completely independent.  I'll be glad to get ACKs/fixes/replacements/etc.


I have checked arch-m68k on ColdFire with and without MMU, and it
is all fine. So for those:

Acked-by: Greg Ungerer 

Regards
Greg




I've merged some of those into for-next, but that can change at any time -
it's not final; for-next will be rebased.  Obviously, I hope to get to
the situation when all of those branches (plus currently missing ones)
get into shape that satisfies architecture maintainers.  Once that happens,
all those branches will be merged into for-next.

I think the model is about final wrt kernel_thread()/kernel_execve()/
sys_execve().  There's one possible change on top of it, but it's reasonably
well-isolated from the rest.  As it is, the model to aim for is this:
* select GENERIC_KERNEL_THREAD and GENERIC_KERNEL_EXECVE
* kill local kernel_thread()/kernel_execve() implementations
* generic kernel_thread() will call your copy_thread() with
NULL regs and fn/arg passed in the pair of arguments that are blindly
passed all the way through to copy_thread() - usp and stack_size resp.
In such case copy_thread() should arrange for the newborn to be woken
up in a function that is very similar to ret_from_fork().  The only
difference is that between the call of schedule_tail() and jumping into
the "return from syscall" code it should call fn(arg), using the data
left for it by copy_thread().
* unlike the previous variant, ret_from_kernel_execve() is not
needed at all; no need to play longjmp()-like games when kernel_thread()
callbacks had been taught to return normally all the way out when
kernel_execve() returns 0; any updates of sp/manipulations of register
windows/etc. will happen without any magic.
* provide current_pt_regs() if needed.  Default is
task_pt_regs(current), but you might want to optimize it and unlike
task_pt_regs() it must work whenever we are in syscall or in a kernel thread.
task_pt_regs(task), OTOH, is required to work only when task can be
interrogated by tracer.
* no more syscalls-from-kernel, which often allows for simplifications
in the syscall entry/exit logics.  I haven't done any of those; up to the
architecture maintainers.

One thing to keep in mind is that right now on SMP architectures
there's the third caller of copy_thread(), besides fork()/clone()/vfork()
(all pass userland pt_regs, with the address being current_pt_regs()) and
kernel_thread() (pass NULL pt_regs, kthread creation time).  It's fork_idle()
and it passes zero-filled pt_regs.  Frankly, I'm not even sure we want to
call copy_thread() in that case - the stuff set up by it goes nowhere.
We do that for each possible secondary CPU on SMP and we do *not* expose
those threads to scheduler.  When CPU gets initialized we have the
secondary bootstrap take that task_struct as current.  Its kernel stack,
thread_info, etc. are set up by said secondary bootstrap, overriding whatever
copy_thread() has done.  Eventually the bootstrap reaches cpu_idle(),
which is where we schedule away.  switch_to() done by schedule() is what
completes setting the things up; at that point they are ready to be woken
up - and not in ret_from_fork(), of course.
For the majority of architectures nothing done by copy_thread() in
that case is used afterwards, so we might as well stop calling it when
copy_process() is called by fork_idle().  I know of only one dubious case -
powerpc sets thread->ksp_limit on copy_th

[PATCH 12/23] printk: Rename clear_seq and clear_idx variables

2012-10-16 Thread Joe Perches
Make these variables more specific to the printk log subsystem
adding prefix printk_log_.  This allows them to become non-static.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   34 +-
 1 file changed, 17 insertions(+), 17 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 709472f..3785ac4 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -231,8 +231,8 @@ static u32 console_idx;
 static enum printk_log_flags console_prev;
 
 /* the next printk record to read after the last 'clear' command */
-static u64 clear_seq;
-static u32 clear_idx;
+static u64 printk_log_clear_seq;
+static u32 printk_log_clear_idx;
 
 #define PREFIX_MAX 32
 #define LOG_LINE_MAX   1024 - PREFIX_MAX
@@ -566,8 +566,8 @@ static loff_t devkmsg_llseek(struct file *file, loff_t 
offset, int whence)
 * like issued by 'dmesg -c'. Reading /dev/kmsg itself
 * changes no global state, and does not clear anything.
 */
-   user->idx = clear_idx;
-   user->seq = clear_seq;
+   user->idx = printk_log_clear_idx;
+   user->seq = printk_log_clear_seq;
break;
case SEEK_END:
/* after the last record */
@@ -1012,18 +1012,18 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
u32 idx;
enum printk_log_flags prev;
 
-   if (clear_seq < printk_log_first_seq) {
+   if (printk_log_clear_seq < printk_log_first_seq) {
/* messages are gone, move to first available one */
-   clear_seq = printk_log_first_seq;
-   clear_idx = printk_log_first_idx;
+   printk_log_clear_seq = printk_log_first_seq;
+   printk_log_clear_idx = printk_log_first_idx;
}
 
/*
 * Find first record that fits, including all following records,
 * into the user-provided buffer for this dump.
 */
-   seq = clear_seq;
-   idx = clear_idx;
+   seq = printk_log_clear_seq;
+   idx = printk_log_clear_idx;
prev = 0;
while (seq < printk_log_next_seq) {
struct printk_log *msg = printk_log_from_idx(idx);
@@ -1035,8 +1035,8 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
}
 
/* move first record forward until length fits into the buffer 
*/
-   seq = clear_seq;
-   idx = clear_idx;
+   seq = printk_log_clear_seq;
+   idx = printk_log_clear_idx;
prev = 0;
while (len > size && seq < printk_log_next_seq) {
struct printk_log *msg = printk_log_from_idx(idx);
@@ -1083,8 +1083,8 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
}
 
if (clear) {
-   clear_seq = printk_log_next_seq;
-   clear_idx = printk_log_next_idx;
+   printk_log_clear_seq = printk_log_next_seq;
+   printk_log_clear_idx = printk_log_next_idx;
}
raw_spin_unlock_irq(&printk_logbuf_lock);
 
@@ -2566,8 +2566,8 @@ void kmsg_dump(enum kmsg_dump_reason reason)
dumper->active = true;
 
raw_spin_lock_irqsave(&printk_logbuf_lock, flags);
-   dumper->cur_seq = clear_seq;
-   dumper->cur_idx = clear_idx;
+   dumper->cur_seq = printk_log_clear_seq;
+   dumper->cur_idx = printk_log_clear_idx;
dumper->next_seq = printk_log_next_seq;
dumper->next_idx = printk_log_next_idx;
raw_spin_unlock_irqrestore(&printk_logbuf_lock, flags);
@@ -2774,8 +2774,8 @@ EXPORT_SYMBOL_GPL(kmsg_dump_get_buffer);
  */
 void kmsg_dump_rewind_nolock(struct kmsg_dumper *dumper)
 {
-   dumper->cur_seq = clear_seq;
-   dumper->cur_idx = clear_idx;
+   dumper->cur_seq = printk_log_clear_seq;
+   dumper->cur_idx = printk_log_clear_idx;
dumper->next_seq = printk_log_next_seq;
dumper->next_idx = printk_log_next_idx;
 }
-- 
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/


RE: [PATCH RESEND 0/8] TI Touchscreen driver updates and Support for TSC/ADC MFD driver

2012-10-16 Thread Patil, Rachna
Hi Samuel,

I have got an ACK from Jonathan and Dmitry on this patch series.
Can you please pull in if there are no further review comments.

Regards,
Rachna.

On Tue, Oct 16, 2012 at 23:12:07, Dmitry Torokhov wrote:
> Hi Rachna,
> 
> On Tue, Oct 16, 2012 at 12:55:37PM +0530, Patil, Rachna wrote:
> > This patch set is a cumulative set of [1] and [2] sent earlier.
> > I have merged the patch set so that the MFD patches apply without any 
> > issues.
> > 
> > Also Note that there are no code changes in either of the patch set, 
> > only rebased on top of linux-next to make sure that all the patches 
> > apply without any conflicts.
> > 
> > This patch set has been tested on AM335x EVM.
> > 
> > [1] "[PATCH 0/4] input: TSC: ti_tscadc: TI Touchscreen driver updates"
> > (http://www.spinics.net/lists/linux-input/msg22107.html)
> > 
> > [2] "[PATCH v5 0/4] Support for TSC/ADC MFD driver"
> > (http://www.spinics.net/lists/linux-input/msg22832.html)
> > 
> > Patil, Rachna (8):
> >   input: TSC: ti_tscadc: Correct register usage
> >   input: TSC: ti_tscadc: Add Step configuration as platform data
> >   input: TSC: ti_tscadc: set FIFO0 threshold Interrupt
> >   input: TSC: ti_tscadc: Remove definition of End Of Interrupt register
> >   input: TSC: ti_tscadc: Rename the existing touchscreen driver
> >   MFD: ti_tscadc: Add support for TI's TSC/ADC MFDevice
> >   input: TSC: ti_tsc: Convert TSC into a MFDevice
> >   IIO : ADC: tiadc: Add support of TI's ADC driver
> 
> I am fine with input portion of the patch series, please merge through MFD 
> tree.
> 
> Thanks.
> 
> --
> Dmitry
> 

--
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 23/23] printk: Move kmsg_dump functions to separate file

2012-10-16 Thread Joe Perches
Generic restructuring.

Create kmsg_dump.c, add to Makefile and remove from printk.c

Signed-off-by: Joe Perches 
---
 kernel/printk/Makefile|1 +
 kernel/printk/kmsg_dump.c |  328 +
 kernel/printk/printk.c|  318 ---
 3 files changed, 329 insertions(+), 318 deletions(-)
 create mode 100644 kernel/printk/kmsg_dump.c

diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
index 7947661..b0072b0 100644
--- a/kernel/printk/Makefile
+++ b/kernel/printk/Makefile
@@ -2,4 +2,5 @@ obj-y   = printk.o
 obj-y  += printk_log.o
 obj-y  += devkmsg.o
 obj-y  += printk_syslog.o
+obj-y  += kmsg_dump.o
 obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/kmsg_dump.c b/kernel/printk/kmsg_dump.c
new file mode 100644
index 000..7962172
--- /dev/null
+++ b/kernel/printk/kmsg_dump.c
@@ -0,0 +1,328 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "printk_log.h"
+
+static DEFINE_SPINLOCK(dump_list_lock);
+static LIST_HEAD(dump_list);
+
+/**
+ * kmsg_dump_register - register a kernel log dumper.
+ * @dumper: pointer to the kmsg_dumper structure
+ *
+ * Adds a kernel log dumper to the system. The dump callback in the
+ * structure will be called when the kernel oopses or panics and must be
+ * set. Returns zero on success and %-EINVAL or %-EBUSY otherwise.
+ */
+int kmsg_dump_register(struct kmsg_dumper *dumper)
+{
+   unsigned long flags;
+   int err = -EBUSY;
+
+   /* The dump callback needs to be set */
+   if (!dumper->dump)
+   return -EINVAL;
+
+   spin_lock_irqsave(&dump_list_lock, flags);
+   /* Don't allow registering multiple times */
+   if (!dumper->registered) {
+   dumper->registered = 1;
+   list_add_tail_rcu(&dumper->list, &dump_list);
+   err = 0;
+   }
+   spin_unlock_irqrestore(&dump_list_lock, flags);
+
+   return err;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_register);
+
+/**
+ * kmsg_dump_unregister - unregister a kmsg dumper.
+ * @dumper: pointer to the kmsg_dumper structure
+ *
+ * Removes a dump device from the system. Returns zero on success and
+ * %-EINVAL otherwise.
+ */
+int kmsg_dump_unregister(struct kmsg_dumper *dumper)
+{
+   unsigned long flags;
+   int err = -EINVAL;
+
+   spin_lock_irqsave(&dump_list_lock, flags);
+   if (dumper->registered) {
+   dumper->registered = 0;
+   list_del_rcu(&dumper->list);
+   err = 0;
+   }
+   spin_unlock_irqrestore(&dump_list_lock, flags);
+   synchronize_rcu();
+
+   return err;
+}
+EXPORT_SYMBOL_GPL(kmsg_dump_unregister);
+
+static bool always_kmsg_dump;
+module_param_named(always_kmsg_dump, always_kmsg_dump, bool, S_IRUGO | 
S_IWUSR);
+
+/**
+ * kmsg_dump - dump kernel log to kernel message dumpers.
+ * @reason: the reason (oops, panic etc) for dumping
+ *
+ * Call each of the registered dumper's dump() callback, which can
+ * retrieve the kmsg records with kmsg_dump_get_line() or
+ * kmsg_dump_get_buffer().
+ */
+void kmsg_dump(enum kmsg_dump_reason reason)
+{
+   struct kmsg_dumper *dumper;
+   unsigned long flags;
+
+   if ((reason > KMSG_DUMP_OOPS) && !always_kmsg_dump)
+   return;
+
+   rcu_read_lock();
+   list_for_each_entry_rcu(dumper, &dump_list, list) {
+   if (dumper->max_reason && reason > dumper->max_reason)
+   continue;
+
+   /* initialize iterator with data about the stored records */
+   dumper->active = true;
+
+   raw_spin_lock_irqsave(&printk_logbuf_lock, flags);
+   dumper->cur_seq = printk_log_clear_seq;
+   dumper->cur_idx = printk_log_clear_idx;
+   dumper->next_seq = printk_log_next_seq;
+   dumper->next_idx = printk_log_next_idx;
+   raw_spin_unlock_irqrestore(&printk_logbuf_lock, flags);
+
+   /* invoke dumper which will iterate over records */
+   dumper->dump(dumper, reason);
+
+   /* reset iterator */
+   dumper->active = false;
+   }
+   rcu_read_unlock();
+}
+
+/**
+ * kmsg_dump_get_line_nolock - retrieve one kmsg log line (unlocked version)
+ * @dumper: registered kmsg dumper
+ * @syslog: include the "<4>" prefixes
+ * @line: buffer to copy the line to
+ * @size: maximum size of the buffer
+ * @len: length of line placed into buffer
+ *
+ * Start at the beginning of the kmsg buffer, with the oldest kmsg
+ * record, and copy one record into the provided buffer.
+ *
+ * Consecutive calls will return the next available record moving
+ * towards the end of the buffer with the youngest messages.
+ *
+ * A return value of FALSE indicates that there are no more records to
+ * read.
+ *
+ * The function is similar to kmsg_dump_get_line(), but grabs no locks.
+ */
+bool kmsg_dump_get_line_nolock(str

[PATCH 11/23] printk: Rename logbuf_lock to printk_logbuf_lock

2012-10-16 Thread Joe Perches
Make this generic name more specific to the printk
subsystem and allow it to become non-static.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |  102 
 1 file changed, 51 insertions(+), 51 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index c87472b..709472f 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -205,10 +205,10 @@ struct printk_log {
 };
 
 /*
- * The logbuf_lock protects kmsg buffer, indices, counters. It is also
+ * The printk_logbuf_lock protects kmsg buffer, indices, counters. It is also
  * used in interesting ways to provide interlocking in console_unlock();
  */
-static DEFINE_RAW_SPINLOCK(logbuf_lock);
+static DEFINE_RAW_SPINLOCK(printk_logbuf_lock);
 
 #ifdef CONFIG_PRINTK
 /* the next printk record to read by syslog(READ) or /proc/kmsg */
@@ -248,7 +248,7 @@ static char __printk_log_buf[__PRINTK_LOG_BUF_LEN] 
__aligned(LOG_ALIGN);
 static char *printk_log_buf = __printk_log_buf;
 static u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
 
-/* cpu currently holding logbuf_lock */
+/* cpu currently holding printk_logbuf_lock */
 static volatile unsigned int logbuf_cpu = UINT_MAX;
 
 /* human readable text of the record */
@@ -438,20 +438,20 @@ static ssize_t devkmsg_read(struct file *file, char 
__user *buf,
ret = mutex_lock_interruptible(&user->lock);
if (ret)
return ret;
-   raw_spin_lock_irq(&logbuf_lock);
+   raw_spin_lock_irq(&printk_logbuf_lock);
while (user->seq == printk_log_next_seq) {
if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
goto out;
}
 
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
ret = wait_event_interruptible(printk_log_wait,
   user->seq != 
printk_log_next_seq);
if (ret)
goto out;
-   raw_spin_lock_irq(&logbuf_lock);
+   raw_spin_lock_irq(&printk_logbuf_lock);
}
 
if (user->seq < printk_log_first_seq) {
@@ -459,7 +459,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
user->idx = printk_log_first_idx;
user->seq = printk_log_first_seq;
ret = -EPIPE;
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
goto out;
}
 
@@ -526,7 +526,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
 
user->idx = printk_log_next(user->idx);
user->seq++;
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
 
if (len > count) {
ret = -EINVAL;
@@ -553,7 +553,7 @@ static loff_t devkmsg_llseek(struct file *file, loff_t 
offset, int whence)
if (offset)
return -ESPIPE;
 
-   raw_spin_lock_irq(&logbuf_lock);
+   raw_spin_lock_irq(&printk_logbuf_lock);
switch (whence) {
case SEEK_SET:
/* the first record */
@@ -577,7 +577,7 @@ static loff_t devkmsg_llseek(struct file *file, loff_t 
offset, int whence)
default:
ret = -EINVAL;
}
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
return ret;
 }
 
@@ -591,14 +591,14 @@ static unsigned int devkmsg_poll(struct file *file, 
poll_table *wait)
 
poll_wait(file, &printk_log_wait, wait);
 
-   raw_spin_lock_irq(&logbuf_lock);
+   raw_spin_lock_irq(&printk_logbuf_lock);
if (user->seq < printk_log_next_seq) {
/* return error when data has vanished underneath us */
if (user->seq < printk_log_first_seq)
ret = POLLIN|POLLRDNORM|POLLERR|POLLPRI;
ret = POLLIN|POLLRDNORM;
}
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
 
return ret;
 }
@@ -622,10 +622,10 @@ static int devkmsg_open(struct inode *inode, struct file 
*file)
 
mutex_init(&user->lock);
 
-   raw_spin_lock_irq(&logbuf_lock);
+   raw_spin_lock_irq(&printk_logbuf_lock);
user->idx = printk_log_first_idx;
user->seq = printk_log_first_seq;
-   raw_spin_unlock_irq(&logbuf_lock);
+   raw_spin_unlock_irq(&printk_logbuf_lock);
 
file->private_data = user;
return 0;
@@ -722,13 +722,13 @@ void __init setup_log_buf(int early)
return;
}
 
-   raw_spin_lock_irqsave(&logbuf_lock, flags);
+   raw_spin_lock_irqsave(&printk_logbuf_lock, flags);
printk_log_buf_len = new_printk_log_buf_len;
printk_log_buf = new_printk_log_buf;
  

[PATCH 22/23] printk: Add printk_syslog.c and .h

2012-10-16 Thread Joe Perches
Move syslog functions to a separate file.
Add compilation unit to Makefile.

Signed-off-by: Joe Perches 
---
 kernel/printk/Makefile|1 +
 kernel/printk/printk.c|  351 +---
 kernel/printk/printk_syslog.c |  354 +
 kernel/printk/printk_syslog.h |   12 ++
 4 files changed, 371 insertions(+), 347 deletions(-)
 create mode 100644 kernel/printk/printk_syslog.c
 create mode 100644 kernel/printk/printk_syslog.h

diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
index bda335f..7947661 100644
--- a/kernel/printk/Makefile
+++ b/kernel/printk/Makefile
@@ -1,4 +1,5 @@
 obj-y  = printk.o
 obj-y  += printk_log.o
 obj-y  += devkmsg.o
+obj-y  += printk_syslog.o
 obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 343b0ce..cba438e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -30,12 +30,10 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -49,6 +47,7 @@
 #include "console_cmdline.h"
 #include "braille.h"
 #include "printk_log.h"
+#include "printk_syslog.h"
 
 /*
  * Architectures can override it:
@@ -122,11 +121,6 @@ EXPORT_SYMBOL(console_set_on_cmdline);
 static int console_may_schedule;
 
 #ifdef CONFIG_PRINTK
-/* the next printk record to read by syslog(READ) or /proc/kmsg */
-static u64 syslog_seq;
-static u32 syslog_idx;
-static enum printk_log_flags syslog_prev;
-static size_t syslog_partial;
 
 /* the next printk record to write to the console */
 static u64 console_seq;
@@ -272,340 +266,6 @@ static inline void boot_delay_msec(void)
 }
 #endif
 
-#ifdef CONFIG_SECURITY_DMESG_RESTRICT
-int dmesg_restrict = 1;
-#else
-int dmesg_restrict;
-#endif
-
-static int syslog_action_restricted(int type)
-{
-   if (dmesg_restrict)
-   return 1;
-   /* Unless restricted, we allow "read all" and "get buffer size" for 
everybody */
-   return type != SYSLOG_ACTION_READ_ALL && type != 
SYSLOG_ACTION_SIZE_BUFFER;
-}
-
-static int check_syslog_permissions(int type, bool from_file)
-{
-   /*
-* If this is from /proc/kmsg and we've already opened it, then we've
-* already done the capabilities checks at open time.
-*/
-   if (from_file && type != SYSLOG_ACTION_OPEN)
-   return 0;
-
-   if (syslog_action_restricted(type)) {
-   if (capable(CAP_SYSLOG))
-   return 0;
-   /* For historical reasons, accept CAP_SYS_ADMIN too, with a 
warning */
-   if (capable(CAP_SYS_ADMIN)) {
-   printk_once(KERN_WARNING "%s (%d): "
-"Attempt to access syslog with CAP_SYS_ADMIN "
-"but no CAP_SYSLOG (deprecated).\n",
-current->comm, task_pid_nr(current));
-   return 0;
-   }
-   return -EPERM;
-   }
-   return 0;
-}
-
-static int syslog_print(char __user *buf, int size)
-{
-   char *text;
-   struct printk_log *msg;
-   int len = 0;
-
-   text = kmalloc(PRINTK_LOG_LINE_MAX + PRINTK_PREFIX_MAX, GFP_KERNEL);
-   if (!text)
-   return -ENOMEM;
-
-   while (size > 0) {
-   size_t n;
-   size_t skip;
-
-   raw_spin_lock_irq(&printk_logbuf_lock);
-   if (syslog_seq < printk_log_first_seq) {
-   /* messages are gone, move to first one */
-   syslog_seq = printk_log_first_seq;
-   syslog_idx = printk_log_first_idx;
-   syslog_prev = 0;
-   syslog_partial = 0;
-   }
-   if (syslog_seq == printk_log_next_seq) {
-   raw_spin_unlock_irq(&printk_logbuf_lock);
-   break;
-   }
-
-   skip = syslog_partial;
-   msg = printk_log_from_idx(syslog_idx);
-   n = printk_msg_print_text(msg, syslog_prev, true, text,
- PRINTK_LOG_LINE_MAX + 
PRINTK_PREFIX_MAX);
-   if (n - syslog_partial <= size) {
-   /* message fits into buffer, move forward */
-   syslog_idx = printk_log_next(syslog_idx);
-   syslog_seq++;
-   syslog_prev = msg->flags;
-   n -= syslog_partial;
-   syslog_partial = 0;
-   } else if (!len){
-   /* partial read(), remember position */
-   n = size;
-   syslog_partial += n;
-   } else
-   n = 0;
-   raw_spin_unlock_irq(&printk_logbuf_lock);
-
-   if (!n)
-   break;
-
-   if (copy_t

[PATCH 21/23] printk: Move functions printk_print_time and printk_msg_print_text

2012-10-16 Thread Joe Perches
Move these functions to printk_log.
Move the static function print_prefix too.
Add "#include " to printk_log.c.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |  112 ---
 kernel/printk/printk_log.c |  114 
 2 files changed, 114 insertions(+), 112 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index cd0d317..343b0ce 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -311,111 +311,6 @@ static int check_syslog_permissions(int type, bool 
from_file)
return 0;
 }
 
-#if defined(CONFIG_PRINTK_TIME)
-static bool printk_time = 1;
-#else
-static bool printk_time;
-#endif
-module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
-
-size_t printk_print_time(u64 ts, char *buf)
-{
-   unsigned long rem_nsec;
-
-   if (!printk_time)
-   return 0;
-
-   if (!buf)
-   return 15;
-
-   rem_nsec = do_div(ts, 10);
-   return sprintf(buf, "[%5lu.%06lu] ",
-  (unsigned long)ts, rem_nsec / 1000);
-}
-
-static size_t print_prefix(const struct printk_log *msg, bool syslog, char 
*buf)
-{
-   size_t len = 0;
-   unsigned int prefix = (msg->facility << 3) | msg->level;
-
-   if (syslog) {
-   if (buf) {
-   len += sprintf(buf, "<%u>", prefix);
-   } else {
-   len += 3;
-   if (prefix > 999)
-   len += 3;
-   else if (prefix > 99)
-   len += 2;
-   else if (prefix > 9)
-   len++;
-   }
-   }
-
-   len += printk_print_time(msg->ts_nsec, buf ? buf + len : NULL);
-   return len;
-}
-
-size_t printk_msg_print_text(const struct printk_log *msg,
-enum printk_log_flags prev,
-bool syslog, char *buf, size_t size)
-{
-   const char *text = printk_log_text(msg);
-   size_t text_size = msg->text_len;
-   bool prefix = true;
-   bool newline = true;
-   size_t len = 0;
-
-   if ((prev & LOG_CONT) && !(msg->flags & LOG_PREFIX))
-   prefix = false;
-
-   if (msg->flags & LOG_CONT) {
-   if ((prev & LOG_CONT) && !(prev & LOG_NEWLINE))
-   prefix = false;
-
-   if (!(msg->flags & LOG_NEWLINE))
-   newline = false;
-   }
-
-   do {
-   const char *next = memchr(text, '\n', text_size);
-   size_t text_len;
-
-   if (next) {
-   text_len = next - text;
-   next++;
-   text_size -= next - text;
-   } else {
-   text_len = text_size;
-   }
-
-   if (buf) {
-   if (print_prefix(msg, syslog, NULL) +
-   text_len + 1 >= size - len)
-   break;
-
-   if (prefix)
-   len += print_prefix(msg, syslog, buf + len);
-   memcpy(buf + len, text, text_len);
-   len += text_len;
-   if (next || newline)
-   buf[len++] = '\n';
-   } else {
-   /* SYSLOG_ACTION_* buffer size only calculation */
-   if (prefix)
-   len += print_prefix(msg, syslog, NULL);
-   len += text_len;
-   if (next || newline)
-   len++;
-   }
-
-   prefix = true;
-   text = next;
-   } while (text);
-
-   return len;
-}
-
 static int syslog_print(char __user *buf, int size)
 {
char *text;
@@ -1186,13 +1081,6 @@ static struct cont {
 struct printk_log *printk_log_from_idx(u32 idx) { return NULL; }
 u32 printk_log_next(u32 idx) { return 0; }
 static void call_console_drivers(int level, const char *text, size_t len) {}
-size_t printk_print_time(u64 ts, char *buf) { return 0; }
-size_t printk_msg_print_text(const struct printk_log *msg,
-enum printk_log_flags prev,
-bool syslog, char *buf, size_t size)
-{
-   return 0;
-}
 
 static size_t cont_print_text(char *text, size_t size) { return 0; }
 
diff --git a/kernel/printk/printk_log.c b/kernel/printk/printk_log.c
index b5c2b8f..d38129c 100644
--- a/kernel/printk/printk_log.c
+++ b/kernel/printk/printk_log.c
@@ -2,6 +2,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "printk_log.h"
 
@@ -135,6 +137,111 @@ void printk_log_store(int facility, int level,
printk_log_next_seq++;
 }
 
+#if defined(CONFIG_PRINTK_TIME)
+static bool printk_time = 1;
+#else
+static bool printk_time;
+#endif
+mo

[PATCH 20/23] printk: Prefix print_time and msg_print_text with printk_

2012-10-16 Thread Joe Perches
Make these static functions global and prefix them with printk_.
Create declarations for these functions in printk_log.h

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   43 ---
 kernel/printk/printk_log.h |4 
 2 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 875e0dc..cd0d317 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -318,7 +318,7 @@ static bool printk_time;
 #endif
 module_param_named(time, printk_time, bool, S_IRUGO | S_IWUSR);
 
-static size_t print_time(u64 ts, char *buf)
+size_t printk_print_time(u64 ts, char *buf)
 {
unsigned long rem_nsec;
 
@@ -352,11 +352,11 @@ static size_t print_prefix(const struct printk_log *msg, 
bool syslog, char *buf)
}
}
 
-   len += print_time(msg->ts_nsec, buf ? buf + len : NULL);
+   len += printk_print_time(msg->ts_nsec, buf ? buf + len : NULL);
return len;
 }
 
-static size_t msg_print_text(const struct printk_log *msg,
+size_t printk_msg_print_text(const struct printk_log *msg,
 enum printk_log_flags prev,
 bool syslog, char *buf, size_t size)
 {
@@ -445,8 +445,8 @@ static int syslog_print(char __user *buf, int size)
 
skip = syslog_partial;
msg = printk_log_from_idx(syslog_idx);
-   n = msg_print_text(msg, syslog_prev, true, text,
-  PRINTK_LOG_LINE_MAX + PRINTK_PREFIX_MAX);
+   n = printk_msg_print_text(msg, syslog_prev, true, text,
+ PRINTK_LOG_LINE_MAX + 
PRINTK_PREFIX_MAX);
if (n - syslog_partial <= size) {
/* message fits into buffer, move forward */
syslog_idx = printk_log_next(syslog_idx);
@@ -512,7 +512,7 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
while (seq < printk_log_next_seq) {
struct printk_log *msg = printk_log_from_idx(idx);
 
-   len += msg_print_text(msg, prev, true, NULL, 0);
+   len += printk_msg_print_text(msg, prev, true, NULL, 0);
prev = msg->flags;
idx = printk_log_next(idx);
seq++;
@@ -525,7 +525,7 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
while (len > size && seq < printk_log_next_seq) {
struct printk_log *msg = printk_log_from_idx(idx);
 
-   len -= msg_print_text(msg, prev, true, NULL, 0);
+   len -= printk_msg_print_text(msg, prev, true, NULL, 0);
prev = msg->flags;
idx = printk_log_next(idx);
seq++;
@@ -540,8 +540,8 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
struct printk_log *msg = printk_log_from_idx(idx);
int textlen;
 
-   textlen = msg_print_text(msg, prev, true, text,
-PRINTK_LOG_LINE_MAX + 
PRINTK_PREFIX_MAX);
+   textlen = printk_msg_print_text(msg, prev, true, text,
+   PRINTK_LOG_LINE_MAX + 
PRINTK_PREFIX_MAX);
if (textlen < 0) {
len = textlen;
break;
@@ -685,7 +685,7 @@ int do_syslog(int type, char __user *buf, int len, bool 
from_file)
while (seq < printk_log_next_seq) {
struct printk_log *msg = 
printk_log_from_idx(idx);
 
-   error += msg_print_text(msg, prev, true, NULL, 
0);
+   error += printk_msg_print_text(msg, prev, true, 
NULL, 0);
idx = printk_log_next(idx);
seq++;
prev = msg->flags;
@@ -936,7 +936,7 @@ static size_t cont_print_text(char *text, size_t size)
size_t len;
 
if (cont.cons == 0 && (console_prev & LOG_NEWLINE)) {
-   textlen += print_time(cont.ts_nsec, text);
+   textlen += printk_print_time(cont.ts_nsec, text);
size -= textlen;
}
 
@@ -1186,9 +1186,14 @@ static struct cont {
 struct printk_log *printk_log_from_idx(u32 idx) { return NULL; }
 u32 printk_log_next(u32 idx) { return 0; }
 static void call_console_drivers(int level, const char *text, size_t len) {}
-static size_t msg_print_text(const struct printk_log *msg,
+size_t printk_print_time(u64 ts, char *buf) { return 0; }
+size_t printk_msg_print_text(const struct printk_log *msg,
 enum printk_log_flags prev,
-bool syslog, cha

[PATCH 19/23] printk: Move devkmsg bits to separate file

2012-10-16 Thread Joe Perches
Move the devkmsg_ functions and kmsg_fops declaration
to devkmsg.c.

Add devkmsg.o to Makefile.

Signed-off-by: Joe Perches 
---
 kernel/printk/Makefile  |1 +
 kernel/printk/devkmsg.c |  309 +++
 kernel/printk/printk.c  |  296 -
 3 files changed, 310 insertions(+), 296 deletions(-)
 create mode 100644 kernel/printk/devkmsg.c

diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
index a692b68..bda335f 100644
--- a/kernel/printk/Makefile
+++ b/kernel/printk/Makefile
@@ -1,3 +1,4 @@
 obj-y  = printk.o
 obj-y  += printk_log.o
+obj-y  += devkmsg.o
 obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/devkmsg.c b/kernel/printk/devkmsg.c
new file mode 100644
index 000..af83290
--- /dev/null
+++ b/kernel/printk/devkmsg.c
@@ -0,0 +1,309 @@
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "printk_log.h"
+
+/* /dev/kmsg - userspace message inject/listen interface */
+struct devkmsg_user {
+   u64 seq;
+   u32 idx;
+   enum printk_log_flags prev;
+   struct mutex lock;
+   char buf[8192];
+};
+
+static ssize_t devkmsg_writev(struct kiocb *iocb, const struct iovec *iv,
+ unsigned long count, loff_t pos)
+{
+   char *buf, *line;
+   int i;
+   int level = default_message_loglevel;
+   int facility = 1;   /* LOG_USER */
+   size_t len = iov_length(iv, count);
+   ssize_t ret = len;
+
+   if (len > PRINTK_LOG_LINE_MAX)
+   return -EINVAL;
+   buf = kmalloc(len+1, GFP_KERNEL);
+   if (buf == NULL)
+   return -ENOMEM;
+
+   line = buf;
+   for (i = 0; i < count; i++) {
+   if (copy_from_user(line, iv[i].iov_base, iv[i].iov_len)) {
+   ret = -EFAULT;
+   goto out;
+   }
+   line += iv[i].iov_len;
+   }
+
+   /*
+* Extract and skip the syslog prefix <[0-9]*>. Coming from userspace
+* the decimal value represents 32bit, the lower 3 bit are the log
+* level, the rest are the log facility.
+*
+* If no prefix or no userspace facility is specified, we
+* enforce LOG_USER, to be able to reliably distinguish
+* kernel-generated messages from userspace-injected ones.
+*/
+   line = buf;
+   if (line[0] == '<') {
+   char *endp = NULL;
+
+   i = simple_strtoul(line+1, &endp, 10);
+   if (endp && endp[0] == '>') {
+   level = i & 7;
+   if (i >> 3)
+   facility = i >> 3;
+   endp++;
+   len -= endp - line;
+   line = endp;
+   }
+   }
+   line[len] = '\0';
+
+   printk_emit(facility, level, NULL, 0, "%s", line);
+out:
+   kfree(buf);
+   return ret;
+}
+
+static ssize_t devkmsg_read(struct file *file, char __user *buf,
+   size_t count, loff_t *ppos)
+{
+   struct devkmsg_user *user = file->private_data;
+   struct printk_log *msg;
+   u64 ts_usec;
+   size_t i;
+   char cont = '-';
+   size_t len;
+   ssize_t ret;
+
+   if (!user)
+   return -EBADF;
+
+   ret = mutex_lock_interruptible(&user->lock);
+   if (ret)
+   return ret;
+   raw_spin_lock_irq(&printk_logbuf_lock);
+   while (user->seq == printk_log_next_seq) {
+   if (file->f_flags & O_NONBLOCK) {
+   ret = -EAGAIN;
+   raw_spin_unlock_irq(&printk_logbuf_lock);
+   goto out;
+   }
+
+   raw_spin_unlock_irq(&printk_logbuf_lock);
+   ret = wait_event_interruptible(printk_log_wait,
+  user->seq != 
printk_log_next_seq);
+   if (ret)
+   goto out;
+   raw_spin_lock_irq(&printk_logbuf_lock);
+   }
+
+   if (user->seq < printk_log_first_seq) {
+   /* our last seen message is gone, return error and reset */
+   user->idx = printk_log_first_idx;
+   user->seq = printk_log_first_seq;
+   ret = -EPIPE;
+   raw_spin_unlock_irq(&printk_logbuf_lock);
+   goto out;
+   }
+
+   msg = printk_log_from_idx(user->idx);
+   ts_usec = msg->ts_nsec;
+   do_div(ts_usec, 1000);
+
+   /*
+* If we couldn't merge continuation line fragments during the print,
+* export the stored flags to allow an optional external merge of the
+* records. Merging the records isn't always neccessarily correct, like
+* when we hit a race during printing. In most cases though, it produces
+* better readable output. 'c' in the r

[PATCH 18/23] printk: Rename and move 2 #defines to printk_log.h

2012-10-16 Thread Joe Perches
Rename the LOG_LINE_MAX and PREFIX_MAX #defines with PRINTK_ prefixes.
Move the defines to printk_log.h
Remove duplicate define too.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   24 ++--
 kernel/printk/printk_log.h |3 +++
 2 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 3b5c10e..43550a5 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -133,9 +133,6 @@ static u64 console_seq;
 static u32 console_idx;
 static enum printk_log_flags console_prev;
 
-#define PREFIX_MAX 32
-#define LOG_LINE_MAX   1024 - PREFIX_MAX
-
 /* cpu currently holding printk_logbuf_lock */
 static volatile unsigned int logbuf_cpu = UINT_MAX;
 
@@ -158,7 +155,7 @@ static ssize_t devkmsg_writev(struct kiocb *iocb, const 
struct iovec *iv,
size_t len = iov_length(iv, count);
ssize_t ret = len;
 
-   if (len > LOG_LINE_MAX)
+   if (len > PRINTK_LOG_LINE_MAX)
return -EINVAL;
buf = kmalloc(len+1, GFP_KERNEL);
if (buf == NULL)
@@ -721,7 +718,7 @@ static int syslog_print(char __user *buf, int size)
struct printk_log *msg;
int len = 0;
 
-   text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
+   text = kmalloc(PRINTK_LOG_LINE_MAX + PRINTK_PREFIX_MAX, GFP_KERNEL);
if (!text)
return -ENOMEM;
 
@@ -745,7 +742,7 @@ static int syslog_print(char __user *buf, int size)
skip = syslog_partial;
msg = printk_log_from_idx(syslog_idx);
n = msg_print_text(msg, syslog_prev, true, text,
-  LOG_LINE_MAX + PREFIX_MAX);
+  PRINTK_LOG_LINE_MAX + PRINTK_PREFIX_MAX);
if (n - syslog_partial <= size) {
/* message fits into buffer, move forward */
syslog_idx = printk_log_next(syslog_idx);
@@ -784,7 +781,7 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
char *text;
int len = 0;
 
-   text = kmalloc(LOG_LINE_MAX + PREFIX_MAX, GFP_KERNEL);
+   text = kmalloc(PRINTK_LOG_LINE_MAX + PRINTK_PREFIX_MAX, GFP_KERNEL);
if (!text)
return -ENOMEM;
 
@@ -840,7 +837,7 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
int textlen;
 
textlen = msg_print_text(msg, prev, true, text,
-LOG_LINE_MAX + PREFIX_MAX);
+PRINTK_LOG_LINE_MAX + 
PRINTK_PREFIX_MAX);
if (textlen < 0) {
len = textlen;
break;
@@ -1160,7 +1157,7 @@ static inline void printk_delay(void)
  * reached the console in case of a kernel crash.
  */
 static struct cont {
-   char buf[LOG_LINE_MAX];
+   char buf[PRINTK_LOG_LINE_MAX];
size_t len; /* length == 0 means unused buffer */
size_t cons;/* bytes written to console */
struct task_struct *owner;  /* task of first print*/
@@ -1262,7 +1259,7 @@ asmlinkage int vprintk_emit(int facility, int level,
const char *fmt, va_list args)
 {
static int recursion_bug;
-   static char textbuf[LOG_LINE_MAX];
+   static char textbuf[PRINTK_LOG_LINE_MAX];
char *text = textbuf;
size_t text_len;
enum printk_log_flags lflags = 0;
@@ -1465,9 +1462,8 @@ EXPORT_SYMBOL(printk);
 
 #else /* CONFIG_PRINTK */
 
-#define LOG_LINE_MAX   0
-#define PREFIX_MAX 0
-#define LOG_LINE_MAX 0
+#define PRINTK_LOG_LINE_MAX0
+#define PRINTK_PREFIX_MAX  0
 static u64 syslog_seq;
 static u32 syslog_idx;
 static u64 console_seq;
@@ -1793,7 +1789,7 @@ out:
  */
 void console_unlock(void)
 {
-   static char text[LOG_LINE_MAX + PREFIX_MAX];
+   static char text[PRINTK_LOG_LINE_MAX + PRINTK_PREFIX_MAX];
static u64 seen_seq;
unsigned long flags;
bool wake_klogd = false;
diff --git a/kernel/printk/printk_log.h b/kernel/printk/printk_log.h
index e846f1d..a7125d5 100644
--- a/kernel/printk/printk_log.h
+++ b/kernel/printk/printk_log.h
@@ -92,6 +92,9 @@ struct printk_log {
 #endif
 #define __PRINTK_LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
 
+#define PRINTK_PREFIX_MAX  32
+#define PRINTK_LOG_LINE_MAX(1024 - PRINTK_PREFIX_MAX)
+
 extern raw_spinlock_t printk_logbuf_lock;
 extern wait_queue_head_t printk_log_wait;
 extern u64 printk_log_first_seq;
-- 
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 17/23] printk: Make wait_queue_head_t printk_log_wait extern

2012-10-16 Thread Joe Perches
Move the variable to the .h file too.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk_log.h |1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/printk/printk_log.h b/kernel/printk/printk_log.h
index 0327f8d..e846f1d 100644
--- a/kernel/printk/printk_log.h
+++ b/kernel/printk/printk_log.h
@@ -93,6 +93,7 @@ struct printk_log {
 #define __PRINTK_LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
 
 extern raw_spinlock_t printk_logbuf_lock;
+extern wait_queue_head_t printk_log_wait;
 extern u64 printk_log_first_seq;
 extern u32 printk_log_first_idx;
 extern u64 printk_log_next_seq;
-- 
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 16/23] printk: Add printk_log.c

2012-10-16 Thread Joe Perches
Move print_log variables and functions into a separate file.

Signed-off-by: Joe Perches 
---
 kernel/printk/Makefile |1 +
 kernel/printk/printk.c |  128 -
 kernel/printk/printk_log.c |  149 
 3 files changed, 150 insertions(+), 128 deletions(-)
 create mode 100644 kernel/printk/printk_log.c

diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
index 85405bd..a692b68 100644
--- a/kernel/printk/Makefile
+++ b/kernel/printk/Makefile
@@ -1,2 +1,3 @@
 obj-y  = printk.o
+obj-y  += printk_log.o
 obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 3b18ade..3b5c10e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -121,12 +121,6 @@ EXPORT_SYMBOL(console_set_on_cmdline);
 /* Flag: console code may call schedule() */
 static int console_may_schedule;
 
-/*
- * The printk_logbuf_lock protects kmsg buffer, indices, counters. It is also
- * used in interesting ways to provide interlocking in console_unlock();
- */
-DEFINE_RAW_SPINLOCK(printk_logbuf_lock);
-
 #ifdef CONFIG_PRINTK
 /* the next printk record to read by syslog(READ) or /proc/kmsg */
 static u64 syslog_seq;
@@ -134,139 +128,17 @@ static u32 syslog_idx;
 static enum printk_log_flags syslog_prev;
 static size_t syslog_partial;
 
-/* index and sequence number of the first record stored in the buffer */
-u64 printk_log_first_seq;
-u32 printk_log_first_idx;
-
-/* index and sequence number of the next record to store in the buffer */
-u64 printk_log_next_seq;
-u32 printk_log_next_idx;
-
 /* the next printk record to write to the console */
 static u64 console_seq;
 static u32 console_idx;
 static enum printk_log_flags console_prev;
 
-/* the next printk record to read after the last 'clear' command */
-u64 printk_log_clear_seq;
-u32 printk_log_clear_idx;
-
 #define PREFIX_MAX 32
 #define LOG_LINE_MAX   1024 - PREFIX_MAX
 
-/* record buffer */
-char __printk_log_buf[__PRINTK_LOG_BUF_LEN] __aligned(PRINTK_LOG_ALIGN);
-char *printk_log_buf = __printk_log_buf;
-u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
-
 /* cpu currently holding printk_logbuf_lock */
 static volatile unsigned int logbuf_cpu = UINT_MAX;
 
-/* human readable text of the record */
-char *printk_log_text(const struct printk_log *msg)
-{
-   return (char *)msg + sizeof(struct printk_log);
-}
-
-/* optional key/value pair dictionary attached to the record */
-char *printk_log_dict(const struct printk_log *msg)
-{
-   return (char *)msg + sizeof(struct printk_log) + msg->text_len;
-}
-
-/* get record by index; idx must point to valid msg */
-struct printk_log *printk_log_from_idx(u32 idx)
-{
-   struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
-
-   /*
-* A length == 0 record is the end of buffer marker. Wrap around and
-* read the message at the start of the buffer.
-*/
-   if (!msg->len)
-   return (struct printk_log *)printk_log_buf;
-   return msg;
-}
-
-/* get next record; idx must point to valid msg */
-u32 printk_log_next(u32 idx)
-{
-   struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
-
-   /* length == 0 indicates the end of the buffer; wrap */
-   /*
-* A length == 0 record is the end of buffer marker. Wrap around and
-* read the message at the start of the buffer as *this* one, and
-* return the one after that.
-*/
-   if (!msg->len) {
-   msg = (struct printk_log *)printk_log_buf;
-   return msg->len;
-   }
-   return idx + msg->len;
-}
-
-/* insert record into the buffer, discard old ones, update heads */
-void printk_log_store(int facility, int level,
- enum printk_log_flags flags, u64 ts_nsec,
- const char *dict, u16 dict_len,
- const char *text, u16 text_len)
-{
-   struct printk_log *msg;
-   u32 size, pad_len;
-
-   /* number of '\0' padding bytes to next message */
-   size = sizeof(struct printk_log) + text_len + dict_len;
-   pad_len = (-size) & (PRINTK_LOG_ALIGN - 1);
-   size += pad_len;
-
-   while (printk_log_first_seq < printk_log_next_seq) {
-   u32 free;
-
-   if (printk_log_next_idx > printk_log_first_idx)
-   free = max(printk_log_buf_len - printk_log_next_idx, 
printk_log_first_idx);
-   else
-   free = printk_log_first_idx - printk_log_next_idx;
-
-   if (free > size + sizeof(struct printk_log))
-   break;
-
-   /* drop old messages until we have enough contiuous space */
-   printk_log_first_idx = printk_log_next(printk_log_first_idx);
-   printk_log_first_seq++;
-   }
-
-   if (printk_log_next_idx + size + sizeof(struct printk_log) >= 
printk_log_buf_le

[PATCH 15/23] printk: Add and use printk_log.h

2012-10-16 Thread Joe Perches
Create a header file for printk_log functions and variables.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   91 +--
 kernel/printk/printk_log.h |  115 
 2 files changed, 116 insertions(+), 90 deletions(-)
 create mode 100644 kernel/printk/printk_log.h

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index bc0b4ed..3b18ade 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -48,6 +48,7 @@
 
 #include "console_cmdline.h"
 #include "braille.h"
+#include "printk_log.h"
 
 /*
  * Architectures can override it:
@@ -121,90 +122,6 @@ EXPORT_SYMBOL(console_set_on_cmdline);
 static int console_may_schedule;
 
 /*
- * The printk log buffer consists of a chain of concatenated variable
- * length records. Every record starts with a record header, containing
- * the overall length of the record.
- *
- * The heads to the first and last entry in the buffer, as well as the
- * sequence numbers of these both entries are maintained when messages
- * are stored..
- *
- * If the heads indicate available messages, the length in the header
- * tells the start next message. A length == 0 for the next message
- * indicates a wrap-around to the beginning of the buffer.
- *
- * Every record carries the monotonic timestamp in microseconds, as well as
- * the standard userspace syslog level and syslog facility. The usual
- * kernel messages use LOG_KERN; userspace-injected messages always carry
- * a matching syslog facility, by default LOG_USER. The origin of every
- * message can be reliably determined that way.
- *
- * The human readable log message directly follows the message header. The
- * length of the message text is stored in the header, the stored message
- * is not terminated.
- *
- * Optionally, a message can carry a dictionary of properties (key/value 
pairs),
- * to provide userspace with a machine-readable message context.
- *
- * Examples for well-defined, commonly used property names are:
- *   DEVICE=b12:8   device identifier
- *b12:8 block dev_t
- *c127:3char dev_t
- *n8netdev ifindex
- *+sound:card0  subsystem:devname
- *   SUBSYSTEM=pci  driver-core subsystem name
- *
- * Valid characters in property names are [a-zA-Z0-9.-_]. The plain text value
- * follows directly after a '=' character. Every property is terminated by
- * a '\0' character. The last property is not terminated.
- *
- * Example of a message structure:
- *     ff 8f 00 00 00 00 00 00  monotonic time in nsec
- *   0008  34 00record is 52 bytes long
- *   000a0b 00  text is 11 bytes long
- *   000c  1f 00dictionary is 23 bytes long
- *   000e03 00  LOG_KERN (facility) LOG_ERR (level)
- *   0010  69 74 27 73 20 61 20 6c  "it's a l"
- * 69 6e 65 "ine"
- *   001b   44 45 56 49 43  "DEVIC"
- * 45 3d 62 38 3a 32 00 44  "E=b8:2\0D"
- * 52 49 56 45 52 3d 62 75  "RIVER=bu"
- * 67   "g"
- *   0032 00 00 00  padding to next message header
- *
- * The 'struct printk_log' buffer header must never be directly exported to
- * userspace, it is a kernel-private implementation detail that might
- * need to be changed in the future, when the requirements change.
- *
- * /dev/kmsg exports the structured data in the following line format:
- *   "level,sequnum,timestamp;\n"
- *
- * The optional key/value pairs are attached as continuation lines starting
- * with a space character and terminated by a newline. All possible
- * non-prinatable characters are escaped in the "\xff" notation.
- *
- * Users of the export format should ignore possible additional values
- * separated by ',', and find the message after the ';' character.
- */
-
-enum printk_log_flags {
-   LOG_NOCONS  = 1,/* already flushed, do not print to console */
-   LOG_NEWLINE = 2,/* text ended with a newline */
-   LOG_PREFIX  = 4,/* text started with a prefix */
-   LOG_CONT= 8,/* text is a fragment of a continuation line */
-};
-
-struct printk_log {
-   u64 ts_nsec;/* timestamp in nanoseconds */
-   u16 len;/* length of entire record */
-   u16 text_len;   /* length of text buffer */
-   u16 dict_len;   /* length of dictionary buffer */
-   u8 facility;/* syslog facility */
-   u8 flags:5; /* internal record flags */
-   u8 level:3; /* syslog level */
-};
-
-/*
  * The printk_logbuf_lock protects kmsg buffer, indices, counters. It is also
  * used in interesting ways to provide interlocking in console_unlock();
  */
@@ -238,12 +15

[PATCH 14/23] printk: Rename LOG_ALIGN to PRINTK_LOG_ALIGN

2012-10-16 Thread Joe Perches
Make the #define more specific to the printk subsystem.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 0134b2e..bc0b4ed 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -239,12 +239,12 @@ u32 printk_log_clear_idx;
 
 /* record buffer */
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
-#define LOG_ALIGN 4
+#define PRINTK_LOG_ALIGN 4
 #else
-#define LOG_ALIGN __alignof__(struct printk_log)
+#define PRINTK_LOG_ALIGN __alignof__(struct printk_log)
 #endif
 #define __PRINTK_LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
-char __printk_log_buf[__PRINTK_LOG_BUF_LEN] __aligned(LOG_ALIGN);
+char __printk_log_buf[__PRINTK_LOG_BUF_LEN] __aligned(PRINTK_LOG_ALIGN);
 char *printk_log_buf = __printk_log_buf;
 u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
 
@@ -306,7 +306,7 @@ void printk_log_store(int facility, int level,
 
/* number of '\0' padding bytes to next message */
size = sizeof(struct printk_log) + text_len + dict_len;
-   pad_len = (-size) & (LOG_ALIGN - 1);
+   pad_len = (-size) & (PRINTK_LOG_ALIGN - 1);
size += pad_len;
 
while (printk_log_first_seq < printk_log_next_seq) {
-- 
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 13/23] printk: Remove static from printk_ variables

2012-10-16 Thread Joe Perches
Allow a separation of functions and variables into
multiple files.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   46 +++---
 1 file changed, 23 insertions(+), 23 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 3785ac4..0134b2e 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -208,7 +208,7 @@ struct printk_log {
  * The printk_logbuf_lock protects kmsg buffer, indices, counters. It is also
  * used in interesting ways to provide interlocking in console_unlock();
  */
-static DEFINE_RAW_SPINLOCK(printk_logbuf_lock);
+DEFINE_RAW_SPINLOCK(printk_logbuf_lock);
 
 #ifdef CONFIG_PRINTK
 /* the next printk record to read by syslog(READ) or /proc/kmsg */
@@ -218,12 +218,12 @@ static enum printk_log_flags syslog_prev;
 static size_t syslog_partial;
 
 /* index and sequence number of the first record stored in the buffer */
-static u64 printk_log_first_seq;
-static u32 printk_log_first_idx;
+u64 printk_log_first_seq;
+u32 printk_log_first_idx;
 
 /* index and sequence number of the next record to store in the buffer */
-static u64 printk_log_next_seq;
-static u32 printk_log_next_idx;
+u64 printk_log_next_seq;
+u32 printk_log_next_idx;
 
 /* the next printk record to write to the console */
 static u64 console_seq;
@@ -231,8 +231,8 @@ static u32 console_idx;
 static enum printk_log_flags console_prev;
 
 /* the next printk record to read after the last 'clear' command */
-static u64 printk_log_clear_seq;
-static u32 printk_log_clear_idx;
+u64 printk_log_clear_seq;
+u32 printk_log_clear_idx;
 
 #define PREFIX_MAX 32
 #define LOG_LINE_MAX   1024 - PREFIX_MAX
@@ -244,27 +244,27 @@ static u32 printk_log_clear_idx;
 #define LOG_ALIGN __alignof__(struct printk_log)
 #endif
 #define __PRINTK_LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
-static char __printk_log_buf[__PRINTK_LOG_BUF_LEN] __aligned(LOG_ALIGN);
-static char *printk_log_buf = __printk_log_buf;
-static u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
+char __printk_log_buf[__PRINTK_LOG_BUF_LEN] __aligned(LOG_ALIGN);
+char *printk_log_buf = __printk_log_buf;
+u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
 
 /* cpu currently holding printk_logbuf_lock */
 static volatile unsigned int logbuf_cpu = UINT_MAX;
 
 /* human readable text of the record */
-static char *printk_log_text(const struct printk_log *msg)
+char *printk_log_text(const struct printk_log *msg)
 {
return (char *)msg + sizeof(struct printk_log);
 }
 
 /* optional key/value pair dictionary attached to the record */
-static char *printk_log_dict(const struct printk_log *msg)
+char *printk_log_dict(const struct printk_log *msg)
 {
return (char *)msg + sizeof(struct printk_log) + msg->text_len;
 }
 
 /* get record by index; idx must point to valid msg */
-static struct printk_log *printk_log_from_idx(u32 idx)
+struct printk_log *printk_log_from_idx(u32 idx)
 {
struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
 
@@ -278,7 +278,7 @@ static struct printk_log *printk_log_from_idx(u32 idx)
 }
 
 /* get next record; idx must point to valid msg */
-static u32 printk_log_next(u32 idx)
+u32 printk_log_next(u32 idx)
 {
struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
 
@@ -296,10 +296,10 @@ static u32 printk_log_next(u32 idx)
 }
 
 /* insert record into the buffer, discard old ones, update heads */
-static void printk_log_store(int facility, int level,
-enum printk_log_flags flags, u64 ts_nsec,
-const char *dict, u16 dict_len,
-const char *text, u16 text_len)
+void printk_log_store(int facility, int level,
+ enum printk_log_flags flags, u64 ts_nsec,
+ const char *dict, u16 dict_len,
+ const char *text, u16 text_len)
 {
struct printk_log *msg;
u32 size, pad_len;
@@ -1690,9 +1690,9 @@ static u32 syslog_idx;
 static u64 console_seq;
 static u32 console_idx;
 static enum printk_log_flags syslog_prev;
-static u64 printk_log_first_seq;
-static u32 printk_log_first_idx;
-static u64 printk_log_next_seq;
+u64 printk_log_first_seq;
+u32 printk_log_first_idx;
+u64 printk_log_next_seq;
 static enum printk_log_flags console_prev;
 static struct cont {
size_t len;
@@ -1700,8 +1700,8 @@ static struct cont {
u8 level;
bool flushed:1;
 } cont;
-static struct printk_log *printk_log_from_idx(u32 idx) { return NULL; }
-static u32 printk_log_next(u32 idx) { return 0; }
+struct printk_log *printk_log_from_idx(u32 idx) { return NULL; }
+u32 printk_log_next(u32 idx) { return 0; }
 static void call_console_drivers(int level, const char *text, size_t len) {}
 static size_t msg_print_text(const struct printk_log *msg,
 enum printk_log_flags prev,
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the bod

[PATCH 10/23] printk: Rename log_wait to printk_log_wait

2012-10-16 Thread Joe Perches
Make this generic variable more specific to the printk
subsystem to allow this variable to be used without
a specific extern.

Also update fs/proc/kmsg.c as it uses log_wait.

Signed-off-by: Joe Perches 
---
 fs/proc/kmsg.c |4 ++--
 kernel/printk/printk.c |   12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/fs/proc/kmsg.c b/fs/proc/kmsg.c
index bd4b5a7..16f2c85 100644
--- a/fs/proc/kmsg.c
+++ b/fs/proc/kmsg.c
@@ -17,7 +17,7 @@
 #include 
 #include 
 
-extern wait_queue_head_t log_wait;
+extern wait_queue_head_t printk_log_wait;
 
 static int kmsg_open(struct inode * inode, struct file * file)
 {
@@ -41,7 +41,7 @@ static ssize_t kmsg_read(struct file *file, char __user *buf,
 
 static unsigned int kmsg_poll(struct file *file, poll_table *wait)
 {
-   poll_wait(file, &log_wait, wait);
+   poll_wait(file, &printk_log_wait, wait);
if (do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_FILE))
return POLLIN | POLLRDNORM;
return 0;
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 341f2d9..c87472b 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -63,7 +63,7 @@ void asmlinkage __attribute__((weak)) early_printk(const char 
*fmt, ...)
 #define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
 #define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
 
-DECLARE_WAIT_QUEUE_HEAD(log_wait);
+DECLARE_WAIT_QUEUE_HEAD(printk_log_wait);
 
 int console_printk[4] = {
DEFAULT_CONSOLE_LOGLEVEL,   /* console_loglevel */
@@ -447,7 +447,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
}
 
raw_spin_unlock_irq(&logbuf_lock);
-   ret = wait_event_interruptible(log_wait,
+   ret = wait_event_interruptible(printk_log_wait,
   user->seq != 
printk_log_next_seq);
if (ret)
goto out;
@@ -589,7 +589,7 @@ static unsigned int devkmsg_poll(struct file *file, 
poll_table *wait)
if (!user)
return POLLERR|POLLNVAL;
 
-   poll_wait(file, &log_wait, wait);
+   poll_wait(file, &printk_log_wait, wait);
 
raw_spin_lock_irq(&logbuf_lock);
if (user->seq < printk_log_next_seq) {
@@ -1122,7 +1122,7 @@ int do_syslog(int type, char __user *buf, int len, bool 
from_file)
error = -EFAULT;
goto out;
}
-   error = wait_event_interruptible(log_wait,
+   error = wait_event_interruptible(printk_log_wait,
 syslog_seq != 
printk_log_next_seq);
if (error)
goto out;
@@ -1948,7 +1948,7 @@ void printk_tick(void)
printk(KERN_WARNING "[sched_delayed] %s", buf);
}
if (pending & PRINTK_PENDING_WAKEUP)
-   wake_up_interruptible(&log_wait);
+   wake_up_interruptible(&printk_log_wait);
}
 }
 
@@ -1961,7 +1961,7 @@ int printk_needs_cpu(int cpu)
 
 void wake_up_klogd(void)
 {
-   if (waitqueue_active(&log_wait))
+   if (waitqueue_active(&printk_log_wait))
this_cpu_or(printk_pending, PRINTK_PENDING_WAKEUP);
 }
 
-- 
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 09/23] printk: Rename enum log_flags to printk_log_flags

2012-10-16 Thread Joe Perches
Make this generic enum more specific to the printk subsystem.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   32 +---
 1 file changed, 17 insertions(+), 15 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 992c064..341f2d9 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -187,7 +187,7 @@ static int console_may_schedule;
  * separated by ',', and find the message after the ';' character.
  */
 
-enum log_flags {
+enum printk_log_flags {
LOG_NOCONS  = 1,/* already flushed, do not print to console */
LOG_NEWLINE = 2,/* text ended with a newline */
LOG_PREFIX  = 4,/* text started with a prefix */
@@ -214,7 +214,7 @@ static DEFINE_RAW_SPINLOCK(logbuf_lock);
 /* the next printk record to read by syslog(READ) or /proc/kmsg */
 static u64 syslog_seq;
 static u32 syslog_idx;
-static enum log_flags syslog_prev;
+static enum printk_log_flags syslog_prev;
 static size_t syslog_partial;
 
 /* index and sequence number of the first record stored in the buffer */
@@ -228,7 +228,7 @@ static u32 printk_log_next_idx;
 /* the next printk record to write to the console */
 static u64 console_seq;
 static u32 console_idx;
-static enum log_flags console_prev;
+static enum printk_log_flags console_prev;
 
 /* the next printk record to read after the last 'clear' command */
 static u64 clear_seq;
@@ -297,7 +297,7 @@ static u32 printk_log_next(u32 idx)
 
 /* insert record into the buffer, discard old ones, update heads */
 static void printk_log_store(int facility, int level,
-enum log_flags flags, u64 ts_nsec,
+enum printk_log_flags flags, u64 ts_nsec,
 const char *dict, u16 dict_len,
 const char *text, u16 text_len)
 {
@@ -360,7 +360,7 @@ static void printk_log_store(int facility, int level,
 struct devkmsg_user {
u64 seq;
u32 idx;
-   enum log_flags prev;
+   enum printk_log_flags prev;
struct mutex lock;
char buf[8192];
 };
@@ -872,7 +872,8 @@ static size_t print_prefix(const struct printk_log *msg, 
bool syslog, char *buf)
return len;
 }
 
-static size_t msg_print_text(const struct printk_log *msg, enum log_flags prev,
+static size_t msg_print_text(const struct printk_log *msg,
+enum printk_log_flags prev,
 bool syslog, char *buf, size_t size)
 {
const char *text = printk_log_text(msg);
@@ -1009,7 +1010,7 @@ static int syslog_print_all(char __user *buf, int size, 
bool clear)
u64 next_seq;
u64 seq;
u32 idx;
-   enum log_flags prev;
+   enum printk_log_flags prev;
 
if (clear_seq < printk_log_first_seq) {
/* messages are gone, move to first available one */
@@ -1194,7 +1195,7 @@ int do_syslog(int type, char __user *buf, int len, bool 
from_file)
} else {
u64 seq = syslog_seq;
u32 idx = syslog_idx;
-   enum log_flags prev = syslog_prev;
+   enum printk_log_flags prev = syslog_prev;
 
error = 0;
while (seq < printk_log_next_seq) {
@@ -1383,11 +1384,11 @@ static struct cont {
u64 ts_nsec;/* time of first print */
u8 level;   /* log level of first message */
u8 facility;/* log level of first message */
-   enum log_flags flags;   /* prefix, newline flags */
+   enum printk_log_flags flags;/* prefix, newline flags */
bool flushed:1; /* buffer sealed and committed */
 } cont;
 
-static void cont_flush(enum log_flags flags)
+static void cont_flush(enum printk_log_flags flags)
 {
if (cont.flushed)
return;
@@ -1481,7 +1482,7 @@ asmlinkage int vprintk_emit(int facility, int level,
static char textbuf[LOG_LINE_MAX];
char *text = textbuf;
size_t text_len;
-   enum log_flags lflags = 0;
+   enum printk_log_flags lflags = 0;
unsigned long flags;
int this_cpu;
int printed_len = 0;
@@ -1688,11 +1689,11 @@ static u64 syslog_seq;
 static u32 syslog_idx;
 static u64 console_seq;
 static u32 console_idx;
-static enum log_flags syslog_prev;
+static enum printk_log_flags syslog_prev;
 static u64 printk_log_first_seq;
 static u32 printk_log_first_idx;
 static u64 printk_log_next_seq;
-static enum log_flags console_prev;
+static enum printk_log_flags console_prev;
 static struct cont {
size_t len;
size_t cons;
@@ -1702,7 +1703,8 @@ static struct cont {
 static struct printk_log *printk_log_from_idx(u32 idx) { return NULL; }
 static u32 printk_log_next(u32 idx) { return 0; }
 static void call_console_drivers(int leve

[PATCH 08/23] printk: Rename log_ variables and functions

2012-10-16 Thread Joe Perches
Make these generic names more specific to the printk
subsystem and allow these variables and functions to
become non-static.

Rename log_text to printk_log_text.
Rename log_dict to printk_log_dict.
Rename log_from_idx to printk_log_from_idx.
Rename log_next to printk_log_next.
Rename log_store to printk_log_store.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |  100 
 1 file changed, 50 insertions(+), 50 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 602a1ab..992c064 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -252,19 +252,19 @@ static u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
 static volatile unsigned int logbuf_cpu = UINT_MAX;
 
 /* human readable text of the record */
-static char *log_text(const struct printk_log *msg)
+static char *printk_log_text(const struct printk_log *msg)
 {
return (char *)msg + sizeof(struct printk_log);
 }
 
 /* optional key/value pair dictionary attached to the record */
-static char *log_dict(const struct printk_log *msg)
+static char *printk_log_dict(const struct printk_log *msg)
 {
return (char *)msg + sizeof(struct printk_log) + msg->text_len;
 }
 
 /* get record by index; idx must point to valid msg */
-static struct printk_log *log_from_idx(u32 idx)
+static struct printk_log *printk_log_from_idx(u32 idx)
 {
struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
 
@@ -278,7 +278,7 @@ static struct printk_log *log_from_idx(u32 idx)
 }
 
 /* get next record; idx must point to valid msg */
-static u32 log_next(u32 idx)
+static u32 printk_log_next(u32 idx)
 {
struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
 
@@ -296,10 +296,10 @@ static u32 log_next(u32 idx)
 }
 
 /* insert record into the buffer, discard old ones, update heads */
-static void log_store(int facility, int level,
- enum log_flags flags, u64 ts_nsec,
- const char *dict, u16 dict_len,
- const char *text, u16 text_len)
+static void printk_log_store(int facility, int level,
+enum log_flags flags, u64 ts_nsec,
+const char *dict, u16 dict_len,
+const char *text, u16 text_len)
 {
struct printk_log *msg;
u32 size, pad_len;
@@ -321,7 +321,7 @@ static void log_store(int facility, int level,
break;
 
/* drop old messages until we have enough contiuous space */
-   printk_log_first_idx = log_next(printk_log_first_idx);
+   printk_log_first_idx = printk_log_next(printk_log_first_idx);
printk_log_first_seq++;
}
 
@@ -337,9 +337,9 @@ static void log_store(int facility, int level,
 
/* fill message */
msg = (struct printk_log *)(printk_log_buf + printk_log_next_idx);
-   memcpy(log_text(msg), text, text_len);
+   memcpy(printk_log_text(msg), text, text_len);
msg->text_len = text_len;
-   memcpy(log_dict(msg), dict, dict_len);
+   memcpy(printk_log_dict(msg), dict, dict_len);
msg->dict_len = dict_len;
msg->facility = facility;
msg->level = level & 7;
@@ -348,7 +348,7 @@ static void log_store(int facility, int level,
msg->ts_nsec = ts_nsec;
else
msg->ts_nsec = local_clock();
-   memset(log_dict(msg) + dict_len, 0, pad_len);
+   memset(printk_log_dict(msg) + dict_len, 0, pad_len);
msg->len = sizeof(struct printk_log) + text_len + dict_len + pad_len;
 
/* insert message */
@@ -463,7 +463,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
goto out;
}
 
-   msg = log_from_idx(user->idx);
+   msg = printk_log_from_idx(user->idx);
ts_usec = msg->ts_nsec;
do_div(ts_usec, 1000);
 
@@ -488,7 +488,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
 
/* escape non-printable characters */
for (i = 0; i < msg->text_len; i++) {
-   unsigned char c = log_text(msg)[i];
+   unsigned char c = printk_log_text(msg)[i];
 
if (c < ' ' || c >= 127 || c == '\\')
len += sprintf(user->buf + len, "\\x%02x", c);
@@ -501,7 +501,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
bool line = true;
 
for (i = 0; i < msg->dict_len; i++) {
-   unsigned char c = log_dict(msg)[i];
+   unsigned char c = printk_log_dict(msg)[i];
 
if (line) {
user->buf[len++] = ' ';
@@ -524,7 +524,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
user->buf[len++] = '\n';
}
 
-   user->idx = log_next(user->idx);
+   user->idx = printk_log_next(user->idx);
us

[PATCH 07/23] printk: Rename log_first and log_next variables

2012-10-16 Thread Joe Perches
Make these generic names more specific to the printk
subsystem and allow these variables to become non-static.

Rename log_first_idx to printk_log_first_idx.
Rename log_first_seq to printk_log_first_seq.
Rename log_next_idx to printk_log_next_idx.
Rename log_next_seq to printk_log_next_seq.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |  150 
 1 file changed, 75 insertions(+), 75 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index c45afb1..602a1ab 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -218,12 +218,12 @@ static enum log_flags syslog_prev;
 static size_t syslog_partial;
 
 /* index and sequence number of the first record stored in the buffer */
-static u64 log_first_seq;
-static u32 log_first_idx;
+static u64 printk_log_first_seq;
+static u32 printk_log_first_idx;
 
 /* index and sequence number of the next record to store in the buffer */
-static u64 log_next_seq;
-static u32 log_next_idx;
+static u64 printk_log_next_seq;
+static u32 printk_log_next_idx;
 
 /* the next printk record to write to the console */
 static u64 console_seq;
@@ -309,34 +309,34 @@ static void log_store(int facility, int level,
pad_len = (-size) & (LOG_ALIGN - 1);
size += pad_len;
 
-   while (log_first_seq < log_next_seq) {
+   while (printk_log_first_seq < printk_log_next_seq) {
u32 free;
 
-   if (log_next_idx > log_first_idx)
-   free = max(printk_log_buf_len - log_next_idx, 
log_first_idx);
+   if (printk_log_next_idx > printk_log_first_idx)
+   free = max(printk_log_buf_len - printk_log_next_idx, 
printk_log_first_idx);
else
-   free = log_first_idx - log_next_idx;
+   free = printk_log_first_idx - printk_log_next_idx;
 
if (free > size + sizeof(struct printk_log))
break;
 
/* drop old messages until we have enough contiuous space */
-   log_first_idx = log_next(log_first_idx);
-   log_first_seq++;
+   printk_log_first_idx = log_next(printk_log_first_idx);
+   printk_log_first_seq++;
}
 
-   if (log_next_idx + size + sizeof(struct printk_log) >= 
printk_log_buf_len) {
+   if (printk_log_next_idx + size + sizeof(struct printk_log) >= 
printk_log_buf_len) {
/*
 * This message + an additional empty header does not fit
 * at the end of the buffer. Add an empty header with len == 0
 * to signify a wrap around.
 */
-   memset(printk_log_buf + log_next_idx, 0, sizeof(struct 
printk_log));
-   log_next_idx = 0;
+   memset(printk_log_buf + printk_log_next_idx, 0, sizeof(struct 
printk_log));
+   printk_log_next_idx = 0;
}
 
/* fill message */
-   msg = (struct printk_log *)(printk_log_buf + log_next_idx);
+   msg = (struct printk_log *)(printk_log_buf + printk_log_next_idx);
memcpy(log_text(msg), text, text_len);
msg->text_len = text_len;
memcpy(log_dict(msg), dict, dict_len);
@@ -352,8 +352,8 @@ static void log_store(int facility, int level,
msg->len = sizeof(struct printk_log) + text_len + dict_len + pad_len;
 
/* insert message */
-   log_next_idx += msg->len;
-   log_next_seq++;
+   printk_log_next_idx += msg->len;
+   printk_log_next_seq++;
 }
 
 /* /dev/kmsg - userspace message inject/listen interface */
@@ -439,7 +439,7 @@ static ssize_t devkmsg_read(struct file *file, char __user 
*buf,
if (ret)
return ret;
raw_spin_lock_irq(&logbuf_lock);
-   while (user->seq == log_next_seq) {
+   while (user->seq == printk_log_next_seq) {
if (file->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
raw_spin_unlock_irq(&logbuf_lock);
@@ -448,16 +448,16 @@ static ssize_t devkmsg_read(struct file *file, char 
__user *buf,
 
raw_spin_unlock_irq(&logbuf_lock);
ret = wait_event_interruptible(log_wait,
-  user->seq != log_next_seq);
+  user->seq != 
printk_log_next_seq);
if (ret)
goto out;
raw_spin_lock_irq(&logbuf_lock);
}
 
-   if (user->seq < log_first_seq) {
+   if (user->seq < printk_log_first_seq) {
/* our last seen message is gone, return error and reset */
-   user->idx = log_first_idx;
-   user->seq = log_first_seq;
+   user->idx = printk_log_first_idx;
+   user->seq = printk_log_first_seq;
ret = -EPIPE;
raw_spin_unlock_irq(&logbuf_lock);
goto out;
@@ -557,

[PATCH 06/23] printk: Rename log_buf and __LOG_BUF_LEN

2012-10-16 Thread Joe Perches
Make these generic names more specific to the printk
subsystem and allow these variables to become non-static.

Rename log_buf to printk_log_buf.
Rename __LOG_BUF_LEN define to __PRINTK_LOG_BUF_LEN.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   76 
 1 file changed, 38 insertions(+), 38 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index da2db46..c45afb1 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -243,10 +243,10 @@ static u32 clear_idx;
 #else
 #define LOG_ALIGN __alignof__(struct printk_log)
 #endif
-#define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
-static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
-static char *log_buf = __log_buf;
-static u32 log_buf_len = __LOG_BUF_LEN;
+#define __PRINTK_LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
+static char __printk_log_buf[__PRINTK_LOG_BUF_LEN] __aligned(LOG_ALIGN);
+static char *printk_log_buf = __printk_log_buf;
+static u32 printk_log_buf_len = __PRINTK_LOG_BUF_LEN;
 
 /* cpu currently holding logbuf_lock */
 static volatile unsigned int logbuf_cpu = UINT_MAX;
@@ -266,21 +266,21 @@ static char *log_dict(const struct printk_log *msg)
 /* get record by index; idx must point to valid msg */
 static struct printk_log *log_from_idx(u32 idx)
 {
-   struct printk_log *msg = (struct printk_log *)(log_buf + idx);
+   struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
 
/*
 * A length == 0 record is the end of buffer marker. Wrap around and
 * read the message at the start of the buffer.
 */
if (!msg->len)
-   return (struct printk_log *)log_buf;
+   return (struct printk_log *)printk_log_buf;
return msg;
 }
 
 /* get next record; idx must point to valid msg */
 static u32 log_next(u32 idx)
 {
-   struct printk_log *msg = (struct printk_log *)(log_buf + idx);
+   struct printk_log *msg = (struct printk_log *)(printk_log_buf + idx);
 
/* length == 0 indicates the end of the buffer; wrap */
/*
@@ -289,7 +289,7 @@ static u32 log_next(u32 idx)
 * return the one after that.
 */
if (!msg->len) {
-   msg = (struct printk_log *)log_buf;
+   msg = (struct printk_log *)printk_log_buf;
return msg->len;
}
return idx + msg->len;
@@ -313,7 +313,7 @@ static void log_store(int facility, int level,
u32 free;
 
if (log_next_idx > log_first_idx)
-   free = max(log_buf_len - log_next_idx, log_first_idx);
+   free = max(printk_log_buf_len - log_next_idx, 
log_first_idx);
else
free = log_first_idx - log_next_idx;
 
@@ -325,18 +325,18 @@ static void log_store(int facility, int level,
log_first_seq++;
}
 
-   if (log_next_idx + size + sizeof(struct printk_log) >= log_buf_len) {
+   if (log_next_idx + size + sizeof(struct printk_log) >= 
printk_log_buf_len) {
/*
 * This message + an additional empty header does not fit
 * at the end of the buffer. Add an empty header with len == 0
 * to signify a wrap around.
 */
-   memset(log_buf + log_next_idx, 0, sizeof(struct printk_log));
+   memset(printk_log_buf + log_next_idx, 0, sizeof(struct 
printk_log));
log_next_idx = 0;
}
 
/* fill message */
-   msg = (struct printk_log *)(log_buf + log_next_idx);
+   msg = (struct printk_log *)(printk_log_buf + log_next_idx);
memcpy(log_text(msg), text, text_len);
msg->text_len = text_len;
memcpy(log_dict(msg), dict, dict_len);
@@ -663,8 +663,8 @@ const struct file_operations kmsg_fops = {
  */
 void log_buf_kexec_setup(void)
 {
-   VMCOREINFO_SYMBOL(log_buf);
-   VMCOREINFO_SYMBOL(log_buf_len);
+   VMCOREINFO_SYMBOL(printk_log_buf);
+   VMCOREINFO_SYMBOL(printk_log_buf_len);
VMCOREINFO_SYMBOL(log_first_idx);
VMCOREINFO_SYMBOL(log_next_idx);
/*
@@ -679,60 +679,60 @@ void log_buf_kexec_setup(void)
 }
 #endif
 
-/* requested log_buf_len from kernel cmdline */
-static unsigned long __initdata new_log_buf_len;
+/* requested printk_log_buf_len from kernel cmdline */
+static unsigned long __initdata new_printk_log_buf_len;
 
-/* save requested log_buf_len since it's too early to process it */
-static int __init log_buf_len_setup(char *str)
+/* save requested printk_log_buf_len since it's too early to process it */
+static int __init printk_log_buf_len_setup(char *str)
 {
unsigned size = memparse(str, &str);
 
if (size)
size = roundup_pow_of_two(size);
-   if (size > log_buf_len)
-   new_log_buf_len = size;
+   if (size > printk_log_buf_len)
+   new_printk_log_buf_len = size;
 
return 0

[PATCH 05/23] printk: rename struct log to struct printk_log

2012-10-16 Thread Joe Perches
Rename the struct to enable moving portions of
printk.c to separate files.

The rename changes output of /proc/vmcoreinfo.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   80 
 1 file changed, 40 insertions(+), 40 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 099c439..da2db46 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -172,7 +172,7 @@ static int console_may_schedule;
  * 67   "g"
  *   0032 00 00 00  padding to next message header
  *
- * The 'struct log' buffer header must never be directly exported to
+ * The 'struct printk_log' buffer header must never be directly exported to
  * userspace, it is a kernel-private implementation detail that might
  * need to be changed in the future, when the requirements change.
  *
@@ -194,7 +194,7 @@ enum log_flags {
LOG_CONT= 8,/* text is a fragment of a continuation line */
 };
 
-struct log {
+struct printk_log {
u64 ts_nsec;/* timestamp in nanoseconds */
u16 len;/* length of entire record */
u16 text_len;   /* length of text buffer */
@@ -241,7 +241,7 @@ static u32 clear_idx;
 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
 #define LOG_ALIGN 4
 #else
-#define LOG_ALIGN __alignof__(struct log)
+#define LOG_ALIGN __alignof__(struct printk_log)
 #endif
 #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT)
 static char __log_buf[__LOG_BUF_LEN] __aligned(LOG_ALIGN);
@@ -252,35 +252,35 @@ static u32 log_buf_len = __LOG_BUF_LEN;
 static volatile unsigned int logbuf_cpu = UINT_MAX;
 
 /* human readable text of the record */
-static char *log_text(const struct log *msg)
+static char *log_text(const struct printk_log *msg)
 {
-   return (char *)msg + sizeof(struct log);
+   return (char *)msg + sizeof(struct printk_log);
 }
 
 /* optional key/value pair dictionary attached to the record */
-static char *log_dict(const struct log *msg)
+static char *log_dict(const struct printk_log *msg)
 {
-   return (char *)msg + sizeof(struct log) + msg->text_len;
+   return (char *)msg + sizeof(struct printk_log) + msg->text_len;
 }
 
 /* get record by index; idx must point to valid msg */
-static struct log *log_from_idx(u32 idx)
+static struct printk_log *log_from_idx(u32 idx)
 {
-   struct log *msg = (struct log *)(log_buf + idx);
+   struct printk_log *msg = (struct printk_log *)(log_buf + idx);
 
/*
 * A length == 0 record is the end of buffer marker. Wrap around and
 * read the message at the start of the buffer.
 */
if (!msg->len)
-   return (struct log *)log_buf;
+   return (struct printk_log *)log_buf;
return msg;
 }
 
 /* get next record; idx must point to valid msg */
 static u32 log_next(u32 idx)
 {
-   struct log *msg = (struct log *)(log_buf + idx);
+   struct printk_log *msg = (struct printk_log *)(log_buf + idx);
 
/* length == 0 indicates the end of the buffer; wrap */
/*
@@ -289,7 +289,7 @@ static u32 log_next(u32 idx)
 * return the one after that.
 */
if (!msg->len) {
-   msg = (struct log *)log_buf;
+   msg = (struct printk_log *)log_buf;
return msg->len;
}
return idx + msg->len;
@@ -301,11 +301,11 @@ static void log_store(int facility, int level,
  const char *dict, u16 dict_len,
  const char *text, u16 text_len)
 {
-   struct log *msg;
+   struct printk_log *msg;
u32 size, pad_len;
 
/* number of '\0' padding bytes to next message */
-   size = sizeof(struct log) + text_len + dict_len;
+   size = sizeof(struct printk_log) + text_len + dict_len;
pad_len = (-size) & (LOG_ALIGN - 1);
size += pad_len;
 
@@ -317,7 +317,7 @@ static void log_store(int facility, int level,
else
free = log_first_idx - log_next_idx;
 
-   if (free > size + sizeof(struct log))
+   if (free > size + sizeof(struct printk_log))
break;
 
/* drop old messages until we have enough contiuous space */
@@ -325,18 +325,18 @@ static void log_store(int facility, int level,
log_first_seq++;
}
 
-   if (log_next_idx + size + sizeof(struct log) >= log_buf_len) {
+   if (log_next_idx + size + sizeof(struct printk_log) >= log_buf_len) {
/*
 * This message + an additional empty header does not fit
 * at the end of the buffer. Add an empty header with len == 0
 * to signify a wrap around.
 */
-   memset(log_buf + log_next_idx, 0, sizeof(struct log));
+   memset(log_buf + log_next_idx, 0, sizeof(struct printk_log));
log_next_idx =

[PATCH 04/23] printk: Use pointer for console_cmdline indexing

2012-10-16 Thread Joe Perches
Make the code a bit more compact by always using a pointer
for the active console_cmdline.

Move overly indented code to correct indent level.

Signed-off-by: Joe Perches 
---
 kernel/printk/printk.c |   49 +---
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index df5b80f..099c439 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1718,18 +1718,19 @@ static int __add_preferred_console(char *name, int idx, 
char *options,
 *  See if this tty is not yet registered, and
 *  if we have a slot free.
 */
-   for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
-   if (strcmp(console_cmdline[i].name, name) == 0 &&
- console_cmdline[i].index == idx) {
-   if (!brl_options)
-   selected_console = i;
-   return 0;
+   for (i = 0, c = console_cmdline;
+i < MAX_CMDLINECONSOLES && c->name[0];
+i++, c++) {
+   if (strcmp(c->name, name) == 0 && c->index == idx) {
+   if (!brl_options)
+   selected_console = i;
+   return 0;
}
+   }
if (i == MAX_CMDLINECONSOLES)
return -E2BIG;
if (!brl_options)
selected_console = i;
-   c = &console_cmdline[i];
strlcpy(c->name, name, sizeof(c->name));
c->options = options;
braille_set_options(c, brl_options);
@@ -1802,15 +1803,15 @@ int update_console_cmdline(char *name, int idx, char 
*name_new, int idx_new, cha
struct console_cmdline *c;
int i;
 
-   for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
-   if (strcmp(console_cmdline[i].name, name) == 0 &&
- console_cmdline[i].index == idx) {
-   c = &console_cmdline[i];
-   strlcpy(c->name, name_new, sizeof(c->name));
-   c->name[sizeof(c->name) - 1] = 0;
-   c->options = options;
-   c->index = idx_new;
-   return i;
+   for (i = 0, c = console_cmdline;
+i < MAX_CMDLINECONSOLES && c->name[0];
+i++, c++)
+   if (strcmp(c->name, name) == 0 && c->index == idx) {
+   strlcpy(c->name, name_new, sizeof(c->name));
+   c->name[sizeof(c->name) - 1] = 0;
+   c->options = options;
+   c->index = idx_new;
+   return i;
}
/* not found */
return -1;
@@ -2218,6 +2219,7 @@ void register_console(struct console *newcon)
int i;
unsigned long flags;
struct console *bcon = NULL;
+   struct console_cmdline *c;
 
/*
 * before we register a new CON_BOOT console, make sure we don't
@@ -2265,24 +2267,25 @@ void register_console(struct console *newcon)
 *  See if this console matches one we selected on
 *  the command line.
 */
-   for (i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0];
-   i++) {
-   if (strcmp(console_cmdline[i].name, newcon->name) != 0)
+   for (i = 0, c = console_cmdline;
+i < MAX_CMDLINECONSOLES && c->name[0];
+i++, c++) {
+   if (strcmp(c->name, newcon->name) != 0)
continue;
if (newcon->index >= 0 &&
-   newcon->index != console_cmdline[i].index)
+   newcon->index != c->index)
continue;
if (newcon->index < 0)
-   newcon->index = console_cmdline[i].index;
+   newcon->index = c->index;
 
-   if (_braille_register_console(newcon, &console_cmdline[i]))
+   if (_braille_register_console(newcon, c))
return;
 
if (newcon->setup &&
newcon->setup(newcon, console_cmdline[i].options) != 0)
break;
newcon->flags |= CON_ENABLED;
-   newcon->index = console_cmdline[i].index;
+   newcon->index = c->index;
if (i == selected_console) {
newcon->flags |= CON_CONSDEV;
preferred_console = selected_console;
-- 
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 03/23] printk: Move braille console support into separate braille.[ch] files

2012-10-16 Thread Joe Perches
Create files with prototypes and static inlines for braille
support.  Make braille_console functions return 1 on success.

cc: Samuel Thibault 
Signed-off-by: Joe Perches 
---
 drivers/accessibility/braille/braille_console.c |9 -
 kernel/printk/Makefile  |1 +
 kernel/printk/braille.c |   48 +++
 kernel/printk/braille.h |   48 +++
 kernel/printk/printk.c  |   44 ++---
 5 files changed, 117 insertions(+), 33 deletions(-)
 create mode 100644 kernel/printk/braille.c
 create mode 100644 kernel/printk/braille.h

diff --git a/drivers/accessibility/braille/braille_console.c 
b/drivers/accessibility/braille/braille_console.c
index d21167b..dc34a5b 100644
--- a/drivers/accessibility/braille/braille_console.c
+++ b/drivers/accessibility/braille/braille_console.c
@@ -359,6 +359,9 @@ int braille_register_console(struct console *console, int 
index,
char *console_options, char *braille_options)
 {
int ret;
+
+   if (!(console->flags & CON_BRL))
+   return 0;
if (!console_options)
/* Only support VisioBraille for now */
console_options = "57600o8";
@@ -374,15 +377,17 @@ int braille_register_console(struct console *console, int 
index,
braille_co = console;
register_keyboard_notifier(&keyboard_notifier_block);
register_vt_notifier(&vt_notifier_block);
-   return 0;
+   return 1;
 }
 
 int braille_unregister_console(struct console *console)
 {
if (braille_co != console)
return -EINVAL;
+   if (!(console->flags & CON_BRL))
+   return 0;
unregister_keyboard_notifier(&keyboard_notifier_block);
unregister_vt_notifier(&vt_notifier_block);
braille_co = NULL;
-   return 0;
+   return 1;
 }
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
index 36d306d..85405bd 100644
--- a/kernel/printk/Makefile
+++ b/kernel/printk/Makefile
@@ -1 +1,2 @@
 obj-y  = printk.o
+obj-$(CONFIG_A11Y_BRAILLE_CONSOLE) += braille.o
diff --git a/kernel/printk/braille.c b/kernel/printk/braille.c
new file mode 100644
index 000..b51087f
--- /dev/null
+++ b/kernel/printk/braille.c
@@ -0,0 +1,48 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+#include 
+#include 
+#include 
+
+#include "console_cmdline.h"
+#include "braille.h"
+
+char *_braille_console_setup(char **str, char **brl_options)
+{
+   if (!memcmp(*str, "brl,", 4)) {
+   *brl_options = "";
+   *str += 4;
+   } else if (!memcmp(str, "brl=", 4)) {
+   *brl_options = *str + 4;
+   *str = strchr(*brl_options, ',');
+   if (!*str)
+   pr_err("need port name after brl=\n");
+   else
+   *((*str)++) = 0;
+   }
+
+   return *str;
+}
+
+int
+_braille_register_console(struct console *console, struct console_cmdline *c)
+{
+   int rtn = 0;
+
+   if (c->brl_options) {
+   console->flags |= CON_BRL;
+   rtn = braille_register_console(console, c->index, c->options,
+  c->brl_options);
+   }
+
+   return rtn;
+}
+
+int
+_braille_unregister_console(struct console *console)
+{
+   if (console->flags & CON_BRL)
+   return braille_unregister_console(console);
+
+   return 0;
+}
diff --git a/kernel/printk/braille.h b/kernel/printk/braille.h
new file mode 100644
index 000..d2e6bc3
--- /dev/null
+++ b/kernel/printk/braille.h
@@ -0,0 +1,48 @@
+#ifndef _PRINTK_BRAILLE_H
+#define _PRINTK_BRAILLE_H
+
+#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
+
+static inline void
+braille_set_options(struct console_cmdline *c, char *brl_options)
+{
+   c->brl_options = brl_options;
+}
+
+char *
+_braille_console_setup(char **str, char **brl_options);
+
+int
+_braille_register_console(struct console *console, struct console_cmdline *c);
+
+int
+_braille_unregister_console(struct console *console);
+
+#else
+
+static inline void
+braille_set_options(struct console_cmdline *c, char *brl_options)
+{
+}
+
+static inline char *
+_braille_console_setup(char **str, char **brl_options)
+{
+   return *str;
+}
+
+static inline int
+_braille_register_console(struct console *console, struct console_cmdline *c)
+{
+   return 0;
+}
+
+static inline int
+_braille_unregister_console(struct console *console)
+{
+   return 0;
+}
+
+#endif
+
+#endif
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 50ef6af..df5b80f 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -47,6 +47,7 @@
 #include 
 
 #include "console_cmdline.h"
+#include "braille.h"
 
 /*
  * Architectures can override it:
@@ -1731,9 +1732,8 @@ static int __add_preferred_console(char *name, int idx, 
char *options,
c = &console_cmdline[i];
strlcpy(c

[PATCH 02/23] printk: Add console_cmdline.h

2012-10-16 Thread Joe Perches
Add an include file for the console_cmdline struct
so that the braille console driver can be separated.

Signed-off-by: Joe Perches 
---
 kernel/printk/console_cmdline.h |   14 ++
 kernel/printk/printk.c  |   13 -
 2 files changed, 18 insertions(+), 9 deletions(-)
 create mode 100644 kernel/printk/console_cmdline.h

diff --git a/kernel/printk/console_cmdline.h b/kernel/printk/console_cmdline.h
new file mode 100644
index 000..cbd69d8
--- /dev/null
+++ b/kernel/printk/console_cmdline.h
@@ -0,0 +1,14 @@
+#ifndef _CONSOLE_CMDLINE_H
+#define _CONSOLE_CMDLINE_H
+
+struct console_cmdline
+{
+   charname[8];/* Name of the driver   */
+   int index;  /* Minor dev. to use*/
+   char*options;   /* Options for the driver   */
+#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
+   char*brl_options;   /* Options for braille driver */
+#endif
+};
+
+#endif
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 1950ecf..50ef6af 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -46,6 +46,8 @@
 #define CREATE_TRACE_POINTS
 #include 
 
+#include "console_cmdline.h"
+
 /*
  * Architectures can override it:
  */
@@ -100,22 +102,15 @@ static int console_locked, console_suspended;
  */
 static struct console *exclusive_console;
 
+
 /*
  * Array of consoles built from command line options (console=)
  */
-struct console_cmdline
-{
-   charname[8];/* Name of the driver   */
-   int index;  /* Minor dev. to use*/
-   char*options;   /* Options for the driver   */
-#ifdef CONFIG_A11Y_BRAILLE_CONSOLE
-   char*brl_options;   /* Options for braille driver */
-#endif
-};
 
 #define MAX_CMDLINECONSOLES 8
 
 static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES];
+
 static int selected_console = -1;
 static int preferred_console = -1;
 int console_set_on_cmdline;
-- 
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 01/23] printk: Move to separate directory for easier modification

2012-10-16 Thread Joe Perches
Make it easier to break up printk into bite-sized chunks.

Remove printk path/filename from comment.

Signed-off-by: Joe Perches 
---
 kernel/Makefile  |3 ++-
 kernel/printk/Makefile   |1 +
 kernel/{ => printk}/printk.c |2 --
 3 files changed, 3 insertions(+), 3 deletions(-)
 create mode 100644 kernel/printk/Makefile
 rename kernel/{ => printk}/printk.c (99%)

diff --git a/kernel/Makefile b/kernel/Makefile
index 0dfeca4..d53980d 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -2,7 +2,7 @@
 # Makefile for the linux kernel.
 #
 
-obj-y = fork.o exec_domain.o panic.o printk.o \
+obj-y = fork.o exec_domain.o panic.o \
cpu.o exit.o itimer.o time.o softirq.o resource.o \
sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
signal.o sys.o kmod.o workqueue.o pid.o task_work.o \
@@ -24,6 +24,7 @@ endif
 
 obj-y += sched/
 obj-y += power/
+obj-y += printk/
 
 ifeq ($(CONFIG_CHECKPOINT_RESTORE),y)
 obj-$(CONFIG_X86) += kcmp.o
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile
new file mode 100644
index 000..36d306d
--- /dev/null
+++ b/kernel/printk/Makefile
@@ -0,0 +1 @@
+obj-y  = printk.o
diff --git a/kernel/printk.c b/kernel/printk/printk.c
similarity index 99%
rename from kernel/printk.c
rename to kernel/printk/printk.c
index 2d607f4..1950ecf 100644
--- a/kernel/printk.c
+++ b/kernel/printk/printk.c
@@ -1,6 +1,4 @@
 /*
- *  linux/kernel/printk.c
- *
  *  Copyright (C) 1991, 1992  Linus Torvalds
  *
  * Modified to make sys_syslog() more flexible: added commands to
-- 
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 00/23] printk: refactoring

2012-10-16 Thread Joe Perches
Make printk a bit more readable.

Joe Perches (23):
  printk: Move to separate directory for easier modification
  printk: Add console_cmdline.h
  printk: Move braille console support into separate braille.[ch] files
  printk: Use pointer for console_cmdline indexing
  printk: rename struct log to struct printk_log
  printk: Rename log_buf and __LOG_BUF_LEN
  printk: Rename log_first and log_next variables
  printk: Rename log_ variables and functions
  printk: Rename enum log_flags to printk_log_flags
  printk: Rename log_wait to printk_log_wait
  printk: Rename logbuf_lock to printk_logbuf_lock
  printk: Rename clear_seq and clear_idx variables
  printk: Remove static from printk_ variables
  printk: Rename LOG_ALIGN to PRINTK_LOG_ALIGN
  printk: Add and use printk_log.h
  printk: Add printk_log.c
  printk: Make wait_queue_head_t printk_log_wait extern
  printk: Rename and move 2 #defines to printk_log.h
  printk: Move devkmsg bits to separate file
  printk: Prefix print_time and msg_print_text with printk_
  printk: Move functions printk_print_time and printk_msg_print_text
  printk: Add printk_syslog.c and .h
  printk: Move kmsg_dump functions to separate file

 drivers/accessibility/braille/braille_console.c |9 +-
 fs/proc/kmsg.c  |4 +-
 kernel/Makefile |3 +-
 kernel/printk.c | 2820 ---
 kernel/printk/Makefile  |6 +
 kernel/printk/braille.c |   48 +
 kernel/printk/braille.h |   48 +
 kernel/printk/console_cmdline.h |   14 +
 kernel/printk/devkmsg.c |  309 +++
 kernel/printk/kmsg_dump.c   |  328 +++
 kernel/printk/printk.c  | 1515 
 kernel/printk/printk_log.c  |  263 +++
 kernel/printk/printk_log.h  |  123 +
 kernel/printk/printk_syslog.c   |  354 +++
 kernel/printk/printk_syslog.h   |   12 +
 15 files changed, 3031 insertions(+), 2825 deletions(-)
 delete mode 100644 kernel/printk.c
 create mode 100644 kernel/printk/Makefile
 create mode 100644 kernel/printk/braille.c
 create mode 100644 kernel/printk/braille.h
 create mode 100644 kernel/printk/console_cmdline.h
 create mode 100644 kernel/printk/devkmsg.c
 create mode 100644 kernel/printk/kmsg_dump.c
 create mode 100644 kernel/printk/printk.c
 create mode 100644 kernel/printk/printk_log.c
 create mode 100644 kernel/printk/printk_log.h
 create mode 100644 kernel/printk/printk_syslog.c
 create mode 100644 kernel/printk/printk_syslog.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/


Re: [PATCH 0/3] Drivers: hv: vmbus

2012-10-16 Thread Jason Wang

On 10/13/2012 04:22 AM, K. Y. Srinivasan wrote:

Fix a bug in the error path of vmbus_open(). As part of this also
get rid of some unnecessary forward declarations as well as empty
functions. I would like to thank Jason Wang
for reporting the issues.

K. Y. Srinivasan (3):
   Drivers: hv: Get rid of unnecessary forward declarations
   Drivers: hv: Cleanup error handling in vmbus_open()
   Drivers: hv: Get rid of hv_ringbuffer_cleanup()

  drivers/hv/channel.c  |   36 +---
  drivers/hv/hyperv_vmbus.h |1 -
  drivers/hv/ring_buffer.c  |   11 ---
  3 files changed, 13 insertions(+), 35 deletions(-)


Thanks.

Acked-by: Jason Wang 
--
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 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Joe Perches
On Wed, 2012-10-17 at 11:25 +0530, Viresh Kumar wrote:
> On 17 October 2012 11:09, Joe Perches  wrote:
> > On Wed, 2012-10-17 at 10:50 +0530, Viresh Kumar wrote:
> >> With debug options on, it is difficult to locate cpufreq core's debug 
> >> prints.
> > []
> >> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> > []
> >> @@ -15,6 +15,8 @@
> >> +#define pr_fmt(fmt) "cpufreq: " fmt
[]
> > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

> Sorry, i am not sure how KBUILD_MODNAME is compiled by kernel.

KBUILD_MODNAME is a #define that is set by scripts/Makefile.lib.

> So, if i try KBUILD_MODNAME with my patch i get prints as:
> 
> KBUILD_MODNAME: 

I believe you are quoting KBUILD_MODNAME

try

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

This should create prefixes like
"cpufreq: "
and
"cpufreq_performance: "

--
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] percpu-rwsem: use barrier in unlock path

2012-10-16 Thread Lai Jiangshan
On 10/17/2012 10:23 AM, Linus Torvalds wrote:
> [ Architecture people, note the potential new SMP barrier! ]
> 
> On Tue, Oct 16, 2012 at 4:30 PM, Mikulas Patocka  wrote:
>> +   /*
>> +* The lock is considered unlocked when p->locked is set to false.
>> +* Use barrier prevent reordering of operations around p->locked.
>> +*/
>> +#if defined(CONFIG_X86) && (!defined(CONFIG_X86_PPRO_FENCE) && 
>> !defined(CONFIG_X86_OOSTORE))
>> +   barrier();
>> +#else
>> +   smp_mb();
>> +#endif
>> p->locked = false;
> 
> Ugh. The #if is too ugly to live.

Even the previous patch is applied, percpu_down_read() still
needs mb() to pair with it.

> 
> This is a classic case of "people who write their own serialization
> primitives invariably get them wrong". And this fix is just horrible,
> and code like this should not be allowed.

One of the most major problems of 62ac665ff9fc07497ca524bd20d6a96893d11071 is 
that
it is merged without Ackeds or Revieweds from Paul or Peter or someone else
who are expert at synchronization/arch memory models.

I suggest any new synchronization should stay in -tip for 2 or more cycles
before merged to mainline.

Thanks,
Lai
--
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 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Viresh Kumar
On 17 October 2012 11:09, Joe Perches  wrote:
> On Wed, 2012-10-17 at 10:50 +0530, Viresh Kumar wrote:
>> With debug options on, it is difficult to locate cpufreq core's debug prints.
> []
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> []
>> @@ -15,6 +15,8 @@
>> +#define pr_fmt(fmt) "cpufreq: " fmt
>
> I'd prefer that
>
> #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>
> be used for all of these.

Hi Joe,

Sorry, i am not sure how KBUILD_MODNAME is compiled by kernel.

If i am not wrong KBUILD_MODNAME would work only for drivers that can
be added as module? If so, then it may not apply here, as most of the stuff
i have updated doesn't call module_init().

So, if i try KBUILD_MODNAME with my patch i get prints as:

KBUILD_MODNAME: 

--
viresh
--
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] backlight: tosa: use devm_gpio_request_one

2012-10-16 Thread Jingoo Han
By using devm_gpio_request_one it is possible to set the direction
and initial value in one shot. Thus, using devm_gpio_request_one
can make the code simpler.

Signed-off-by: Jingoo Han 
Cc: Richard Purdie 
Cc: Dmitry Baryshkov 
---
 drivers/video/backlight/tosa_bl.c  |6 ++
 drivers/video/backlight/tosa_lcd.c |8 ++--
 2 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/video/backlight/tosa_bl.c 
b/drivers/video/backlight/tosa_bl.c
index 49342e1..60f258c 100644
--- a/drivers/video/backlight/tosa_bl.c
+++ b/drivers/video/backlight/tosa_bl.c
@@ -92,14 +92,12 @@ static int __devinit tosa_bl_probe(struct i2c_client 
*client,
 
data->comadj = sharpsl_param.comadj == -1 ? COMADJ_DEFAULT : 
sharpsl_param.comadj;
 
-   ret = devm_gpio_request(&client->dev, TOSA_GPIO_BL_C20MA, "backlight");
+   ret = devm_gpio_request_one(&client->dev, TOSA_GPIO_BL_C20MA,
+   GPIOF_OUT_INIT_LOW, "backlight");
if (ret) {
dev_dbg(&data->bl->dev, "Unable to request gpio!\n");
return ret;
}
-   ret = gpio_direction_output(TOSA_GPIO_BL_C20MA, 0);
-   if (ret)
-   return ret;
 
i2c_set_clientdata(client, data);
data->i2c = client;
diff --git a/drivers/video/backlight/tosa_lcd.c 
b/drivers/video/backlight/tosa_lcd.c
index 33047a6..00a8f21 100644
--- a/drivers/video/backlight/tosa_lcd.c
+++ b/drivers/video/backlight/tosa_lcd.c
@@ -193,17 +193,13 @@ static int __devinit tosa_lcd_probe(struct spi_device 
*spi)
data->spi = spi;
dev_set_drvdata(&spi->dev, data);
 
-   ret = devm_gpio_request(&spi->dev, TOSA_GPIO_TG_ON, "tg #pwr");
+   ret = devm_gpio_request_one(&spi->dev, TOSA_GPIO_TG_ON,
+   GPIOF_OUT_INIT_LOW, "tg #pwr");
if (ret < 0)
goto err_gpio_tg;
 
mdelay(60);
 
-   ret = gpio_direction_output(TOSA_GPIO_TG_ON, 0);
-   if (ret < 0)
-   goto err_gpio_tg;
-
-   mdelay(60);
tosa_lcd_tg_init(data);
 
tosa_lcd_tg_on(data);
-- 
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/


[PATCH 1/2] backlight: lms283gf05: use devm_gpio_request_one

2012-10-16 Thread Jingoo Han
By using devm_gpio_request_one it is possible to set the direction
and initial value in one shot. Thus, using devm_gpio_request_one
can make the code simpler.

Signed-off-by: Jingoo Han 
Cc: Richard Purdie 
Cc: Marek Vasut 
---
 drivers/video/backlight/lms283gf05.c |   10 +++---
 1 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/video/backlight/lms283gf05.c 
b/drivers/video/backlight/lms283gf05.c
index ea43f22..c452210 100644
--- a/drivers/video/backlight/lms283gf05.c
+++ b/drivers/video/backlight/lms283gf05.c
@@ -158,13 +158,9 @@ static int __devinit lms283gf05_probe(struct spi_device 
*spi)
int ret = 0;
 
if (pdata != NULL) {
-   ret = devm_gpio_request(&spi->dev, pdata->reset_gpio,
-   "LMS285GF05 RESET");
-   if (ret)
-   return ret;
-
-   ret = gpio_direction_output(pdata->reset_gpio,
-   !pdata->reset_inverted);
+   ret = devm_gpio_request_one(&spi->dev, pdata->reset_gpio,
+   GPIOF_DIR_OUT | !pdata->reset_inverted,
+   "LMS285GF05 RESET");
if (ret)
return ret;
}
-- 
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/


[PATCH 2/2] KVM: VMX: report internal error for MMIO #PF due to delivery event

2012-10-16 Thread Xiao Guangrong
The #PF with PFEC.RSV = 1 indicates that the guest is accessing MMIO, we
can not fix it if it is caused by delivery event. Reporting internal error
for this case

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/vmx.c |   26 --
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index b8a0841..6599e45 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4287,16 +4287,6 @@ static int handle_exception(struct kvm_vcpu *vcpu)
if (is_machine_check(intr_info))
return handle_machine_check(vcpu);

-   if ((vect_info & VECTORING_INFO_VALID_MASK) &&
-   !is_page_fault(intr_info)) {
-   vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
-   vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_SIMUL_EX;
-   vcpu->run->internal.ndata = 2;
-   vcpu->run->internal.data[0] = vect_info;
-   vcpu->run->internal.data[1] = intr_info;
-   return 0;
-   }
-
if ((intr_info & INTR_INFO_INTR_TYPE_MASK) == INTR_TYPE_NMI_INTR)
return 1;  /* already handled by vmx_vcpu_run() */

@@ -4315,6 +4305,22 @@ static int handle_exception(struct kvm_vcpu *vcpu)
error_code = 0;
if (intr_info & INTR_INFO_DELIVER_CODE_MASK)
error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
+
+   /*
+* The #PF with PFEC.RSVD = 1 indicates the guest is accessing
+* MMIO, it is better to report an internal error.
+* See the comments in vmx_handle_exit.
+*/
+   if ((vect_info & VECTORING_INFO_VALID_MASK) &&
+   !(is_page_fault(intr_info) && !(error_code & PFERR_RSVD_MASK))) {
+   vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
+   vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_SIMUL_EX;
+   vcpu->run->internal.ndata = 2;
+   vcpu->run->internal.data[0] = vect_info;
+   vcpu->run->internal.data[1] = intr_info;
+   return 0;
+   }
+
if (is_page_fault(intr_info)) {
/* EPT won't cause page fault directly */
BUG_ON(enable_ept);
-- 
1.7.7.6

--
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] KVM: VMX: report internal error for the unhandleable event

2012-10-16 Thread Xiao Guangrong
VM exits during Event Delivery is really unexpected if it is not caused
by Exceptions/EPT-VIOLATION/TASK_SWITCH, we'd better to report an internal
and freeze the guest, the VMM has the chance to check the guest

Signed-off-by: Xiao Guangrong 
---
 arch/x86/kvm/vmx.c  |   19 +++
 include/linux/kvm.h |8 ++--
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad6b1dd..b8a0841 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -5979,13 +5979,24 @@ static int vmx_handle_exit(struct kvm_vcpu *vcpu)
return 0;
}

+   /*
+* Note:
+* Do not try to fix EXIT_REASON_EPT_MISCONFIG if it caused by
+* delivery event since it indicates guest is accessing MMIO.
+* The vm-exit can be triggered again after return to guest that
+* will cause infinite loop.
+*/
if ((vectoring_info & VECTORING_INFO_VALID_MASK) &&
(exit_reason != EXIT_REASON_EXCEPTION_NMI &&
exit_reason != EXIT_REASON_EPT_VIOLATION &&
-   exit_reason != EXIT_REASON_TASK_SWITCH))
-   printk(KERN_WARNING "%s: unexpected, valid vectoring info "
-  "(0x%x) and exit reason is 0x%x\n",
-  __func__, vectoring_info, exit_reason);
+   exit_reason != EXIT_REASON_TASK_SWITCH)) {
+   vcpu->run->exit_reason = KVM_EXIT_INTERNAL_ERROR;
+   vcpu->run->internal.suberror = KVM_INTERNAL_ERROR_DELIVERY_EV;
+   vcpu->run->internal.ndata = 2;
+   vcpu->run->internal.data[0] = vectoring_info;
+   vcpu->run->internal.data[1] = exit_reason;
+   return 0;
+   }

if (unlikely(!cpu_has_virtual_nmis() && vmx->soft_vnmi_blocked &&
!(is_guest_mode(vcpu) && nested_cpu_has_virtual_nmis(
diff --git a/include/linux/kvm.h b/include/linux/kvm.h
index 65ad5c6..494a84c 100644
--- a/include/linux/kvm.h
+++ b/include/linux/kvm.h
@@ -170,8 +170,12 @@ struct kvm_pit_config {
 #define KVM_EXIT_WATCHDOG 21

 /* For KVM_EXIT_INTERNAL_ERROR */
-#define KVM_INTERNAL_ERROR_EMULATION 1
-#define KVM_INTERNAL_ERROR_SIMUL_EX 2
+/* Emulate instruction failed. */
+#define KVM_INTERNAL_ERROR_EMULATION   1
+/* Encounter unexpected simultaneous exceptions. */
+#define KVM_INTERNAL_ERROR_SIMUL_EX2
+/* Encounter unexpected vm-exit due to delivery event. */
+#define KVM_INTERNAL_ERROR_DELIVERY_EV 3

 /* for KVM_RUN, returned by mmap(vcpu_fd, offset=0) */
 struct kvm_run {
-- 
1.7.7.6

--
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: new execve/kernel_thread design

2012-10-16 Thread Al Viro
On Wed, Oct 17, 2012 at 09:32:34AM +0400, Max Filippov wrote:
> On Wed, Oct 17, 2012 at 2:35 AM, Al Viro  wrote:
> > [apologies for enormous Cc; I've talked to some of you in private mail
> > and after being politely asked to explain WTF was all that thing for
> > and how was it supposed to work, well...]
> 
> [...]
> 
> > Not even a tentative patchset: hexagon, openrisc, tile, xtensa.
> 
> I'm doing xtensa part.

Thanks; I hope this variant is going to be less painful than messing with
ret_from_kernel_execve()...

> BTW, what linus-arch ML might be for?

A typo, noticed only when I got a bounce ;-)
My apologies...
--
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 for-3.7] mm, mempolicy: fix printing stack contents in numa_maps

2012-10-16 Thread Kamezawa Hiroyuki

(2012/10/17 14:24), David Rientjes wrote:

On Wed, 17 Oct 2012, Dave Jones wrote:


BUG: sleeping function called from invalid context at kernel/mutex.c:269
in_atomic(): 1, irqs_disabled(): 0, pid: 8558, name: trinity-child2
3 locks on stack by trinity-child2/8558:
  #0: held: (&p->lock){+.+.+.}, instance: 88010c9a00b0, at: 
[] seq_lseek+0x3f/0x120
  #1: held: (&mm->mmap_sem){++}, instance: 88013956f7c8, at: 
[] m_start+0xa7/0x190
  #2: held: (&(&p->alloc_lock)->rlock){+.+...}, instance: 88011fc64f30, at: 
[] show_numa_map+0x14f/0x610
Pid: 8558, comm: trinity-child2 Not tainted 3.7.0-rc1+ #32
Call Trace:
  [] __might_sleep+0x14c/0x200
  [] mutex_lock_nested+0x2e/0x50
  [] mpol_shared_policy_lookup+0x33/0x90
  [] shmem_get_policy+0x33/0x40
  [] get_vma_policy+0x3a/0x90
  [] show_numa_map+0x163/0x610
  [] ? pid_maps_open+0x20/0x20
  [] ? pagemap_hugetlb_range+0xf0/0xf0
  [] show_pid_numa_map+0x13/0x20
  [] traverse+0xf2/0x230
  [] seq_lseek+0xab/0x120
  [] sys_lseek+0x7b/0xb0
  [] tracesys+0xe1/0xe6



Hmm, looks like we need to change the refcount semantics entirely.  We'll
need to make get_vma_policy() always take a reference and then drop it
accordingly.  This work sif get_vma_policy() can grab a reference while
holding task_lock() for the task policy fallback case.

Comments on this approach?


I think this refcounting is better than using task_lock().

Thanks,
-Kame

--
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] power_supply: Added helper function to get the ps object from supplied_to list

2012-10-16 Thread Pallala, Ramakrishna
Hi Anton,

Please ignore the following patch.
 
> This patch adds a helper function in the power supply core to get the power
> supply object from supplied_to list based on power supply attribute.
> 
> Signed-off-by: Ramakrishna Pallala 
> ---
>  drivers/power/power_supply_core.c |   19 +++
>  include/linux/power_supply.h  |3 +++
>  2 files changed, 22 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/power/power_supply_core.c
> b/drivers/power/power_supply_core.c
> index ff990d2..5845a76 100644
> --- a/drivers/power/power_supply_core.c
> +++ b/drivers/power/power_supply_core.c
> @@ -158,6 +158,25 @@ struct power_supply
> *power_supply_get_by_name(char *name)  }
> EXPORT_SYMBOL_GPL(power_supply_get_by_name);
> 
> +struct power_supply *power_supply_get_by_suppliedto(struct power_supply
> *psy,
> + enum power_supply_property psp, int intval) {
> + union power_supply_propval ret = {0,};
> + struct power_supply *pst;
> + int i;
> +
> + for (i = 0; i < psy->num_supplicants; i++) {
> + pst = power_supply_get_by_name(psy->supplied_to[i]);
> + if (!pst || pst->get_property(pst, psp, &ret))
> + continue;
> + if (ret.intval == intval)
> + return pst;
> + }
> +
> + return NULL;
> +}
> +EXPORT_SYMBOL_GPL(power_supply_get_by_suppliedto);
> +
>  int power_supply_powers(struct power_supply *psy, struct device *dev)  {
>   return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers"); diff --
> git a/include/linux/power_supply.h b/include/linux/power_supply.h index
> 0bafbb1..3cfee0c 100644
> --- a/include/linux/power_supply.h
> +++ b/include/linux/power_supply.h
> @@ -219,6 +219,9 @@ struct power_supply_info {  };
> 
>  extern struct power_supply *power_supply_get_by_name(char *name);
> +extern struct power_supply *power_supply_get_by_suppliedto(
> + struct power_supply *psy,
> + enum power_supply_property psp, int intval);
>  extern void power_supply_changed(struct power_supply *psy);  extern int
> power_supply_am_i_supplied(struct power_supply *psy);  extern int
> power_supply_set_battery_charged(struct power_supply *psy);
> --
> 1.7.0.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/


Re: [PATCH 1/2] cpufreq: Improve debug prints

2012-10-16 Thread Joe Perches
On Wed, 2012-10-17 at 10:50 +0530, Viresh Kumar wrote:
> With debug options on, it is difficult to locate cpufreq core's debug prints.
[]
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
[]
> @@ -15,6 +15,8 @@
> +#define pr_fmt(fmt) "cpufreq: " fmt

I'd prefer that

#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

be used for all of these.

--
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 PATCH v1 2/3] PM / Runtime: force memory allocation with no I/O during runtime_resume callbcack

2012-10-16 Thread Rafael J. Wysocki
On Tuesday 16 of October 2012 23:59:42 Ming Lei wrote:
> This patch applies the introduced memalloc_noio_save() and
> memalloc_noio_restore() to force memory allocation with no I/O
> during runtime_resume callback.
> 
> Cc: Alan Stern 
> Cc: Oliver Neukum 
> Cc: Rafael J. Wysocki 
> Signed-off-by: Ming Lei 
> ---
>  drivers/base/power/runtime.c |   14 ++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
> index 3148b10..c71a8f0 100644
> --- a/drivers/base/power/runtime.c
> +++ b/drivers/base/power/runtime.c
> @@ -503,6 +503,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);
>  
> @@ -652,7 +653,20 @@ static int rpm_resume(struct device *dev, int rpmflags)
>   if (!callback && dev->driver && dev->driver->pm)
>   callback = dev->driver->pm->runtime_resume;
>  
> + /*
> +  * 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. The easiest approach is
> +  * to forbid I/O inside runtime_resume of all devices.
> +  *
> +  * In fact, it can be done only if the deivce is a block device
> +  * or there is one block device descendant. But that may become
> +  * complicated and not efficient because device tree traversing
> +  * is involved.
> +  */
> + memalloc_noio_save(noio_flag);
>   retval = rpm_callback(callback, dev);
> + memalloc_noio_restore(noio_flag);
>   if (retval) {
>   __update_runtime_status(dev, RPM_SUSPENDED);
>   pm_runtime_cancel_pending(dev);

This appears to be a bit too heavy handed.  First of all, it seems to affect
all memory allocations going in parallel with the resume callback.  Second,
it affects all resume callbacks, not only those where the problem really
appears.  As a result, we are likely to get some memory allocation failures
that don't happen without the patch and don't really need to happen at all.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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: new execve/kernel_thread design

2012-10-16 Thread Max Filippov
On Wed, Oct 17, 2012 at 2:35 AM, Al Viro  wrote:
> [apologies for enormous Cc; I've talked to some of you in private mail
> and after being politely asked to explain WTF was all that thing for
> and how was it supposed to work, well...]

[...]

> Not even a tentative patchset: hexagon, openrisc, tile, xtensa.

I'm doing xtensa part.

BTW, what linus-arch ML might be for?

-- 
Thanks.
-- Max
--
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 for-3.7] mm, mempolicy: fix printing stack contents in numa_maps

2012-10-16 Thread David Rientjes
On Wed, 17 Oct 2012, Dave Jones wrote:

> BUG: sleeping function called from invalid context at kernel/mutex.c:269
> in_atomic(): 1, irqs_disabled(): 0, pid: 8558, name: trinity-child2
> 3 locks on stack by trinity-child2/8558:
>  #0: held: (&p->lock){+.+.+.}, instance: 88010c9a00b0, at: 
> [] seq_lseek+0x3f/0x120
>  #1: held: (&mm->mmap_sem){++}, instance: 88013956f7c8, at: 
> [] m_start+0xa7/0x190
>  #2: held: (&(&p->alloc_lock)->rlock){+.+...}, instance: 
> 88011fc64f30, at: [] show_numa_map+0x14f/0x610
> Pid: 8558, comm: trinity-child2 Not tainted 3.7.0-rc1+ #32
> Call Trace:
>  [] __might_sleep+0x14c/0x200
>  [] mutex_lock_nested+0x2e/0x50
>  [] mpol_shared_policy_lookup+0x33/0x90
>  [] shmem_get_policy+0x33/0x40
>  [] get_vma_policy+0x3a/0x90
>  [] show_numa_map+0x163/0x610
>  [] ? pid_maps_open+0x20/0x20
>  [] ? pagemap_hugetlb_range+0xf0/0xf0
>  [] show_pid_numa_map+0x13/0x20
>  [] traverse+0xf2/0x230
>  [] seq_lseek+0xab/0x120
>  [] sys_lseek+0x7b/0xb0
>  [] tracesys+0xe1/0xe6
> 

Hmm, looks like we need to change the refcount semantics entirely.  We'll 
need to make get_vma_policy() always take a reference and then drop it 
accordingly.  This work sif get_vma_policy() can grab a reference while 
holding task_lock() for the task policy fallback case.

Comments on this approach?
---
 fs/proc/task_mmu.c |4 +---
 include/linux/mm.h |3 +--
 mm/hugetlb.c   |4 ++--
 mm/mempolicy.c |   41 ++---
 4 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -1178,11 +1178,9 @@ static int show_numa_map(struct seq_file *m, void *v, 
int is_pid)
walk.private = md;
walk.mm = mm;
 
-   task_lock(task);
pol = get_vma_policy(task, vma, vma->vm_start);
mpol_to_str(buffer, sizeof(buffer), pol, 0);
-   mpol_cond_put(pol);
-   task_unlock(task);
+   __mpol_put(pol);
 
seq_printf(m, "%08lx %s", vma->vm_start, buffer);
 
diff --git a/include/linux/mm.h b/include/linux/mm.h
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -216,8 +216,7 @@ struct vm_operations_struct {
 * get_policy() op must add reference [mpol_get()] to any policy at
 * (vma,addr) marked as MPOL_SHARED.  The shared policy infrastructure
 * in mm/mempolicy.c will do this automatically.
-* get_policy() must NOT add a ref if the policy at (vma,addr) is not
-* marked as MPOL_SHARED. vma policies are protected by the mmap_sem.
+* vma policies are protected by the mmap_sem.
 * If no [shared/vma] mempolicy exists at the addr, get_policy() op
 * must return NULL--i.e., do not "fallback" to task or system default
 * policy.
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -568,13 +568,13 @@ retry_cpuset:
}
}
 
-   mpol_cond_put(mpol);
+   __mpol_put(mpol);
if (unlikely(!put_mems_allowed(cpuset_mems_cookie) && !page))
goto retry_cpuset;
return page;
 
 err:
-   mpol_cond_put(mpol);
+   __mpol_put(mpol);
return NULL;
 }
 
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -1536,39 +1536,41 @@ asmlinkage long compat_sys_mbind(compat_ulong_t start, 
compat_ulong_t len,
  *
  * Returns effective policy for a VMA at specified address.
  * Falls back to @task or system default policy, as necessary.
- * Current or other task's task mempolicy and non-shared vma policies must be
- * protected by task_lock(task) by the caller.
- * Shared policies [those marked as MPOL_F_SHARED] require an extra reference
- * count--added by the get_policy() vm_op, as appropriate--to protect against
- * freeing by another task.  It is the caller's responsibility to free the
- * extra reference for shared policies.
+ * Increments the reference count of the returned mempolicy, it is the caller's
+ * responsibility to decrement with __mpol_put().
+ * Requires vma->vm_mm->mmap_sem to be held for vma policies and takes
+ * task_lock(task) for task policy fallback.
  */
 struct mempolicy *get_vma_policy(struct task_struct *task,
struct vm_area_struct *vma, unsigned long addr)
 {
-   struct mempolicy *pol = task->mempolicy;
+   struct mempolicy *pol;
+
+   task_lock(task);
+   pol = task->mempolicy;
+   mpol_get(pol);
+   task_unlock(task);
 
if (vma) {
if (vma->vm_ops && vma->vm_ops->get_policy) {
struct mempolicy *vpol = vma->vm_ops->get_policy(vma,
addr);
-   if (vpol)
+   if (vpol) {
+   mpol_put(pol);
pol = vpol;
+   if (!mpol_needs_cond_ref(pol))
+

[PATCH 2/2] cpufreq: Debugging options for the cpufreq subsystem

2012-10-16 Thread Viresh Kumar
This adds Kconfig options for DEBUG and VERBOSE_DEBUG to the cpufreq subsystem,
This is pretty useful for developers who want to debug cpufreq subsystem and
don't want to editing the Makefile manually each time they want to debug.

Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/Kconfig  | 14 ++
 drivers/cpufreq/Makefile |  4 
 2 files changed, 18 insertions(+)

diff --git a/drivers/cpufreq/Kconfig b/drivers/cpufreq/Kconfig
index e24a2a1..b9ee95c 100644
--- a/drivers/cpufreq/Kconfig
+++ b/drivers/cpufreq/Kconfig
@@ -17,6 +17,20 @@ config CPU_FREQ
 
 if CPU_FREQ
 
+config CPUFREQ_DEBUG
+bool "cpufreq debugging"
+help
+ This is an option for use by developers; most people should say N
+ here. This enables cpufreq core and debugging.
+
+config CPUFREQ_VDEBUG
+bool "cpufreq verbose debugging"
+depends on CPUFREQ_DEBUG != n
+help
+ This is an option for use by developers; most people should say N
+ here.  This enables deeper (more verbose) debugging of the cpufreq
+ core and drivers.
+
 config CPU_FREQ_TABLE
tristate
 
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile
index fe4cd26..df4cfc8 100644
--- a/drivers/cpufreq/Makefile
+++ b/drivers/cpufreq/Makefile
@@ -1,3 +1,7 @@
+# CPUfreq core & drivers debugging
+ccflags-$(CONFIG_CPUFREQ_DEBUG):= -DDEBUG
+ccflags-$(CONFIG_CPUFREQ_VDEBUG)   += -DVERBOSE_DEBUG
+
 # CPUfreq core
 obj-$(CONFIG_CPU_FREQ) += cpufreq.o
 # CPUfreq stats
-- 
1.7.12.rc2.18.g61b472e


--
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] cpufreq: Improve debug prints

2012-10-16 Thread Viresh Kumar
With debug options on, it is difficult to locate cpufreq core's debug prints.
Fix this by prefixing debug prints with:

"cpufreq: "

Signed-off-by: Viresh Kumar 
---
 drivers/cpufreq/cpufreq.c | 2 ++
 drivers/cpufreq/cpufreq_performance.c | 2 ++
 drivers/cpufreq/cpufreq_powersave.c   | 2 ++
 drivers/cpufreq/cpufreq_userspace.c   | 2 ++
 drivers/cpufreq/freq_table.c  | 2 ++
 5 files changed, 10 insertions(+)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index db6e337..bcbc99d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -15,6 +15,8 @@
  *
  */
 
+#define pr_fmt(fmt) "cpufreq: " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_performance.c 
b/drivers/cpufreq/cpufreq_performance.c
index f13a8a9..67e3232 100644
--- a/drivers/cpufreq/cpufreq_performance.c
+++ b/drivers/cpufreq/cpufreq_performance.c
@@ -10,6 +10,8 @@
  *
  */
 
+#define pr_fmt(fmt) "cpufreq: " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_powersave.c 
b/drivers/cpufreq/cpufreq_powersave.c
index 4c2eb51..eb974b6 100644
--- a/drivers/cpufreq/cpufreq_powersave.c
+++ b/drivers/cpufreq/cpufreq_powersave.c
@@ -10,6 +10,8 @@
  *
  */
 
+#define pr_fmt(fmt) "cpufreq: " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/cpufreq_userspace.c 
b/drivers/cpufreq/cpufreq_userspace.c
index bedac1a..6d7ccdb 100644
--- a/drivers/cpufreq/cpufreq_userspace.c
+++ b/drivers/cpufreq/cpufreq_userspace.c
@@ -11,6 +11,8 @@
  *
  */
 
+#define pr_fmt(fmt) "cpufreq: " fmt
+
 #include 
 #include 
 #include 
diff --git a/drivers/cpufreq/freq_table.c b/drivers/cpufreq/freq_table.c
index 90431cb..246949c 100644
--- a/drivers/cpufreq/freq_table.c
+++ b/drivers/cpufreq/freq_table.c
@@ -9,6 +9,8 @@
  *
  */
 
+#define pr_fmt(fmt) "cpufreq: " fmt
+
 #include 
 #include 
 #include 
-- 
1.7.12.rc2.18.g61b472e


--
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 1/1] Update acpi_root_bridge_list in container hotplug path.

2012-10-16 Thread Yinghai Lu
On Tue, Oct 16, 2012 at 8:25 PM, Tang Chen  wrote:
> Hi Yinghai,
>
> List acpi_root_bridge_list is only updated when kernel is booting,
> or in _handle_hotplug_event_root() when handling ACPI_NOTIFY_DEVICE_CHECK
> event on a pci root bridge device. But when we hotplug a container, which
> contains one or more pci root bridges, container_notify_cb() will be
> called but not _handle_hotplug_event_root(). As a result,
> acpi_root_bridge_list won't be updated.
>
> This patch makes the following api and struct public in pci_root_hp.h,
> struct acpi_root_bridge;
> add_acpi_root_bridge()
> remove_acpi_root_bridge()
> acpi_root_handle_to_bridge()
> and call add_acpi_root_bridge() in acpi_bus_check_add() and call
> remove_acpi_root_bridge() in acpi_bus_remove().
>
> This patch is based on Lu Yinghai's git tree branch 
> for-pci-split-pci-root-hp-2.
>
> Signed-off-by: Tang Chen 
> ---
> diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
> index 6ca2eaf..c258064 100644
> --- a/drivers/acpi/scan.c
> +++ b/drivers/acpi/scan.c
> @@ -12,6 +12,7 @@
>  #include 
>
>  #include 
> +#include 
>
>  #include "internal.h"
>
> @@ -1265,8 +1266,17 @@ int acpi_bus_remove(struct acpi_device *dev, int 
> rmdevice)
> dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
> device_release_driver(&dev->dev);
>
> -   if (rmdevice)
> +   if (rmdevice) {
> +   if (acpi_is_root_bridge(dev->handle)) {
> +   struct acpi_root_bridge *bridge;
> +
> +   bridge = acpi_root_handle_to_bridge(dev->handle);
> +   if (bridge)
> +   remove_acpi_root_bridge(bridge);
> +   }
> +
> acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
> +   }

no, we don't need that.

after closely looking, it seems we can dump acpi_root_bridge.

please check if attached patch could work with container path.

Thanks

Yinghai


kill_remove_acpi_root_bridge.patch
Description: Binary data


Re: [PATCH v9 05/12] x86, hotplug, suspend: Online CPU0 for suspend or hibernate

2012-10-16 Thread Rafael J. Wysocki
On Tuesday 16 of October 2012 22:12:27 Yu, Fenghua wrote:
> > On 10/16/2012 09:47 PM, Rafael J. Wysocki wrote:
> > > On Tuesday 16 of October 2012 11:05:18 Srivatsa S. Bhat wrote:
> > >> On 10/16/2012 02:20 AM, Rafael J. Wysocki wrote:
> > >>> On Friday 12 of October 2012 09:09:42 Fenghua Yu wrote:
> >  From: Fenghua Yu 
> > 
> >  +
> >  +/*
> >  + * When bsp_check() is called in hibernate and suspend, cpu
> > hotplug
> >  + * is disabled already. So it's unnessary to handle race
> > condition between
> >  + * cpumask query and cpu hotplug.
> >  + */
> >  +static int bsp_check(void)
> >  +{
> >  +  if (cpumask_first(cpu_online_mask) != 0) {
> >  +  pr_warn("CPU0 is offline.\n");
> >  +  return -ENODEV;
> >  +  }
> >  +
> >  +  return 0;
> >  +}
> >  +
> >  +static int bsp_pm_callback(struct notifier_block *nb, unsigned
> > long action,
> >  + void *ptr)
> >  +{
> >  +  int ret = 0;
> >  +
> >  +  switch (action) {
> >  +  case PM_SUSPEND_PREPARE:
> >  +  case PM_HIBERNATION_PREPARE:
> >  +  ret = bsp_check();
> >  +  break;
> >  +  default:
> >  +  break;
> >  +  }
> >  +  return notifier_from_errno(ret);
> >  +}
> >  +
> > >>>
> > >>> I wonder if there's anything preventing CPU0 from becoming offline
> > after you've
> > >>> done this check and before user space is frozen?
> > >>>
> > >>
> > >> Hi Rafael,
> > >>
> > >> bsp_pm_callback runs as a low priority notifier callback,
> > specifically with lower
> > >> priority than the cpu_hotplug_pm_callback (as mentioned in the
> > comment below).
> > >> And cpu_hotplug_pm_callback disables regular CPU hotplug (till the
> > suspend/resume
> > >> sequence is complete).. So there is no chance for CPU0 to become
> > offline after that.
> > >>
> > >> Or, are you thinking of some other scenario where CPU0 can go
> > offline?
> > >
> > > No, that should be fine technically, but designs relying on notifier
> > priority
> > > for correctness are kind of fragile.
> > >
> > 
> > Hmm.. I agree.
> > 
> > > Would it be possible to make cpu_hotplug_pm_callback() do the BSP
> > online check?
> > >
> > 
> > Good idea! I think that could be done quite easily. And while doing
> > that, it would
> > be good to rethink what to do in patch 12/12 (Debug CPU0 hotplug) to
> > fix the bug I
> > pointed out in my other mail.
> 
> Why is this design relying on notifier priority fragile? I don't get it.

Because things like this are often overlooked by people trying to optimize
stuff and the fact that you have to add a comment explaining that dependency
only means that it is not exactly straightforward.

Moreover, you should also add a corresponding comment in the other notifier
indicating that its priority should be higher than the priority of the
new thing and explaining why.

> The priority in pm_notifier() is in a well designed API. This code just
> follows the API to assign lower priority for bsp_pm_callback than
> cpu_hotplug_pm_callback. Unless your justification is that the API of
> pm_notifier() is fragile, I think this patch should be ok.

I really think that notifiers are fragile in general and this particular
one is no exception.

> It's not a good idea to move bsp_pm_callback() into
> cpu_hotplug_pm_callback(). There is no architecture specific hook to
> call x86 bsp specific hotplug in cpu_hotplug_pm_callback(). Moving
> bsp_pm_callback() into cpu_hotplug_pm_callback() is hacking while 
> this patch follows well defined API and has better coding.

I'm not sure it is better coding.  You really want one piece of code
to always follow another piece of code and the best way to ensure
that is to execute them both explicitly in sequence.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
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 PATCH v1 1/3] mm: teach mm by current context info to not do I/O during memory allocation

2012-10-16 Thread Kamezawa Hiroyuki
(2012/10/17 0:59), Ming Lei wrote:
> 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 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)
> 
> - 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.
> 
> 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" 
> Cc: linux-mm 
> Signed-off-by: Minchan Kim 
> Signed-off-by: Ming Lei 
> ---
>   include/linux/sched.h |   11 +++
>   mm/page_alloc.c   |   10 +-
>   mm/vmscan.c   |   13 +
>   3 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index f6961c9..c149ae7 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1811,6 +1811,7 @@ extern void thread_group_times(struct task_struct *p, 
> cputime_t *ut, cputime_t *
>   #define PF_FROZEN   0x0001  /* frozen for system suspend */
>   #define PF_FSTRANS  0x0002  /* inside a filesystem transaction */
>   #define PF_KSWAPD   0x0004  /* I am kswapd */
> +#define PF_MEMALLOC_NOIO 0x0008  /* Allocating memory without IO 
> involved */
>   #define PF_LESS_THROTTLE 0x0010 /* Throttle me less: I clean memory */
>   #define PF_KTHREAD  0x0020  /* I am a kernel thread */
>   #define PF_RANDOMIZE0x0040  /* randomize virtual address 
> space */
> @@ -1848,6 +1849,16 @@ extern void thread_group_times(struct task_struct *p, 
> cputime_t *ut, cputime_t *
>   #define tsk_used_math(p) ((p)->flags & PF_USED_MATH)
>   #define used_math() tsk_used_math(current)
>   
> +#define memalloc_noio() (current->flags & PF_MEMALLOC_NOIO)
> +#define memalloc_noio_save(noio_flag) do { \
> + (noio_flag) = current->flags & PF_MEMALLOC_NOIO; \
> + current->flags |= PF_MEMALLOC_NOIO; \
> +} while (0)
> +#define memalloc_noio_restore(noio_flag) do { \
> + if (!(noio_flag)) \
> + current->flags &= ~PF_MEMALLOC_NOIO; \
> +} while (0)
> +
>   /*
>* task->jobctl flags
>*/
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 8e1be1c..e3746dd 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -2630,10 +2630,18 @@ retry_cpuset:
>   page = get_page_from_freelist(gfp_mask|__GFP_HARDWALL, nodemask, order,
>   zonelist, high_zoneidx, alloc_flags,
>   preferred_zone, migratetype);
> - if (unlikely(!page))
> + if (unlikely(!page)) {
> + /*
> +  * Resume, block IO and its error handling path
> +  * can deadlock because I/O on the device might not
> +  * complete.
> +  */
> + if (unlikely(memalloc_noio()))
> + gfp_mask &= ~GFP_IOFS;
>   page = __alloc_pages_slowpath(gfp_mask, order,
>   zonelist, high_zoneidx, nodemask,
>   preferred_zone, migratetype);
> + }
>   
>   trace_mm_page_alloc(page, order, gfp_mask, migratetype);
>   
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 1e9aa66..6647805 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -3298,6 +3298,19 @@ static int __zone_reclaim(struct zone *zone, gfp_t 
> gfp_mask, unsigned int order)
>   };
>   unsigned long 

[PATCH] Fix 'perf' build on sparc.

2012-10-16 Thread David Miller

More UAPI stuff.

Signed-off-by: David S. Miller 

diff --git a/tools/perf/perf.h b/tools/perf/perf.h
index 2762877..c50985e 100644
--- a/tools/perf/perf.h
+++ b/tools/perf/perf.h
@@ -57,7 +57,7 @@ void get_term_dimensions(struct winsize *ws);
 #endif
 
 #ifdef __sparc__
-#include "../../arch/sparc/include/asm/unistd.h"
+#include "../../arch/sparc/include/uapi/asm/unistd.h"
 #define rmb()  asm volatile("":::"memory")
 #define cpu_relax()asm volatile("":::"memory")
 #define CPUINFO_PROC   "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/


[GIT] Networking

2012-10-16 Thread David Miller

1) Fix regression in /proc/net/if_inet6, sometimes devices do not
   get listed.  From Eric Dumazet.

2) Add IPSEC networking sub-section to MAINTAINERS.

3) S390 networking fixes from Hendrik Brueckner and
   Stefan Raspl.

4) Fix enslavement of devices that can't do VLAN properly, from
   Jiri Pirko.

5) SCTP sack handling fix from Zijie Pan.

Please pull, thanks a lot.

The following changes since commit 29bb4cc5e0547a7589556f8629e39016c5d203c0:

  docbook: networking: fix file paths for uapi headers (2012-10-15 08:04:41 
-0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net.git master

for you to fetch changes up to 9f0d3c2781baa1102108e16efbe640dd74564a7c:

  ipv6: addrconf: fix /proc/net/if_inet6 (2012-10-16 14:41:47 -0400)


David S. Miller (1):
  MAINTAINERS: Add explicit section for IPSEC networking.

Dmitry Kravkov (1):
  bnx2x: fix handling mf storage modes

Eric Dumazet (1):
  ipv6: addrconf: fix /proc/net/if_inet6

Hendrik Brueckner (1):
  smsgiucv: reestablish IUCV path after resume

Jiri Pirko (1):
  vlan: fix bond/team enslave of vlan challenged slave/port

Stefan Raspl (1):
  qeth: fix deadlock between recovery and bonding driver

Zijie Pan (1):
  sctp: fix call to SCTP_CMD_PROCESS_SACK in sctp_cmd_interpreter()

 MAINTAINERS | 14 ++
 drivers/net/bonding/bond_main.c |  2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | 10 +++---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c  |  2 +-
 drivers/s390/net/qeth_l2_main.c | 11 ++-
 drivers/s390/net/qeth_l3_main.c | 11 ++-
 drivers/s390/net/smsgiucv.c |  2 +-
 net/8021q/vlan_core.c   |  9 -
 net/ipv6/addrconf.c | 15 +--
 net/sctp/sm_sideeffect.c|  3 ++-
 10 files changed, 55 insertions(+), 24 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/


[GIT] Sparc

2012-10-16 Thread David Miller

Two sparc64 perf bug fixes and add a sysrq facility so I can diagnose
these kinds of problems more quickly in the future.

Please pull, thanks a lot.

The following changes since commit ddffeb8c4d0331609ef2581d84de4d763607bd37:

  Linux 3.7-rc1 (2012-10-14 14:41:04 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc.git master

for you to fetch changes up to e793d8c6740f8fe704fa216e95685f4d92c4c4b9:

  sparc64: Fix bit twiddling in sparc_pmu_enable_event(). (2012-10-16 13:05:25 
-0700)


David S. Miller (3):
  sparc64: Like x86 we should check current->mm during perf backtrace 
generation.
  sparc64: Add global PMU register dumping via sysrq.
  sparc64: Fix bit twiddling in sparc_pmu_enable_event().

 Documentation/sysrq.txt |   1 +
 arch/sparc/include/asm/ptrace.h |  13 +++-
 arch/sparc/include/asm/smp_64.h |   2 ++
 arch/sparc/kernel/perf_event.c  |  15 +
 arch/sparc/kernel/process_64.c  | 120 
+++
 arch/sparc/kernel/smp_64.c  |  11 +++
 arch/sparc/mm/ultra.S   |  64 ++--
 drivers/tty/sysrq.c |   1 +
 8 files changed, 198 insertions(+), 29 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 1/2] PM / devfreq: fix sscanf handling for writable sysfs entries

2012-10-16 Thread MyungJoo Ham
> sscanf returns 0 when an invalid parameter like:
> echo -n "a">min_freq
> is attempted. Returning back the return result(0) will
> cause the command not to return back to command
> prompt.
> 
> Instead, just return -EINVAL when sscanf does not
> return 1.
> 
> This is done for min_freq, max_freq and polling_interval
> 
> Cc: MyungJoo Ham 
> Cc: Kyungmin Park 
> Cc: "Rafael J. Wysocki" 
> Cc: Kevin Hilman 
> Cc: linux...@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> 
> Signed-off-by: Nishanth Menon 

Acked-by: MyungJoo Ham 



Re: [PATCH] PM / devfreq: kernel-doc typo corrections

2012-10-16 Thread MyungJoo Ham
> Parameter documentation needs a ':' for scripts/kernel-doc
> to parse properly.
> 
> Minor fixes for ones warned by:
> ./scripts/kernel-doc -text drivers/devfreq/devfreq.c>/dev/null
> 
> Cc: "Rafael J. Wysocki" 
> Cc: Kevin Hilman 
> Cc: MyungJoo Ham 
> Cc: Kyungmin Park 
> Cc: linux-kernel@vger.kernel.org
> Cc: linux...@vger.kernel.org
> 
> Signed-off-by: Nishanth Menon 

Acked-by: MyungJoo Ham 



[PATCH] backlight: ili9320: add missing SPI dependency

2012-10-16 Thread Jingoo Han
This patch adds this missing SPI dependency and prevents
the driver from buiding without SPI, because funtion of
spi driver is used in this driver.

Signed-off-by: Jingoo Han 
Cc: Richard Purdie 
Cc: Ben Dooks 
---
 drivers/video/backlight/Kconfig |3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig
index c101697..765a945 100644
--- a/drivers/video/backlight/Kconfig
+++ b/drivers/video/backlight/Kconfig
@@ -60,7 +60,8 @@ config LCD_LTV350QV
  The LTV350QV panel is present on all ATSTK1000 boards.
 
 config LCD_ILI9320
-   tristate
+   tristate "ILI Technology ILI9320 controller support"
+   depends on SPI
help
  If you have a panel based on the ILI9320 controller chip
  then say y to include a power driver for it.
-- 
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: ata4.00: failed to get Identify Device Data, Emask 0x1

2012-10-16 Thread Robert Hancock

On 10/16/2012 07:38 PM, Aaron Lu wrote:

On 10/16/2012 11:18 PM, Borislav Petkov wrote:

On Tue, Oct 16, 2012 at 03:58:24PM +0100, Alan Cox wrote:

Can you check whether 3.6 works on them. I know 3.6 is horribly broken
on several brands of AHCI controller (Jmicron for example). Dunno
where Jeff is on fixing the regressions ?


If by "works" you mean I don't see the message there, then yes, it does.
Logs say the message started appearing on Oct 4th after me building
Linus master after the merge window started.

Ok, let me test 3.6.2 just in case .. yes, no error message
there.


This is brought by commit: 65fe1f0f66a57380229a4ced844188103135f37b,
ahci: implement aggressive SATA device sleep support.

Shane, got time to take a look? This debug message made people
uncomfortable :-)


I don't have whatever version of ATA command set defines this command, 
but surely there's some identify bit which lists whether this log page 
is supported. Right now checking for it is only conditional on NCQ support.

--
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: [RESEND PATCH 1/2] perf, cpu hotplug: Run CPU_STARTING notifiers with irqs disabled

2012-10-16 Thread Srivatsa S. Bhat
On 10/17/2012 12:04 AM, Paul E. McKenney wrote:
> On Tue, Oct 16, 2012 at 10:07:15PM +0530, Srivatsa S. Bhat wrote:
>> On 10/16/2012 10:01 PM, Paul E. McKenney wrote:
>>> On Tue, Oct 16, 2012 at 01:28:10PM +0530, Srivatsa S. Bhat wrote:
 The CPU_STARTING notifiers are supposed to be run with irqs disabled. But 
 the
 perf_cpu_notifier() macro invokes them without doing that. Fix it.
>>>
>>> Color me confused...
>>
>> Hehe, I believe the context provided by diff tricked you ;-)
>> The function I am referring to is perf_cpu_notifier(), not
>> perf_event_task_tick() :-)
> 
> It did indeed fool me!  And indeed, checking the code did indeed show
> that the name of interest if perf_cpu_notifier().
> 
> When using the correct name, I do indeed find places where it is
> called with interrupts enabled.  So...
> 
> Reviewed-by: Paul E. McKenney 
>

Great! Thank you :)

Regards,
Srivatsa S. Bhat

>>
>>>  Isn't perf_event_task_tick() invoked only
>>> from scheduler_tick(), which always has interrupts disabled?
>>>
>>> Or are you needing to invoke it from somewhere else?
>>>
>>> Thanx, Paul
>>>
 Signed-off-by: Srivatsa S. Bhat 
 ---

  include/linux/perf_event.h |3 +++
  1 file changed, 3 insertions(+)

 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
 index 2e90235..0647805 100644
 --- a/include/linux/perf_event.h
 +++ b/include/linux/perf_event.h
 @@ -803,10 +803,13 @@ static inline void perf_event_task_tick(void)
 { }
  do {  
 \
static struct notifier_block fn##_nb __cpuinitdata =\
{ .notifier_call = fn, .priority = CPU_PRI_PERF };  \
 +  unsigned long flags;\
fn(&fn##_nb, (unsigned long)CPU_UP_PREPARE, \
(void *)(unsigned long)smp_processor_id()); \
 +  local_irq_save(flags);  \
fn(&fn##_nb, (unsigned long)CPU_STARTING,   \
(void *)(unsigned long)smp_processor_id()); \
 +  local_irq_restore(flags);   \
fn(&fn##_nb, (unsigned long)CPU_ONLINE, \
(void *)(unsigned long)smp_processor_id()); \
register_cpu_notifier(&fn##_nb);\

>>

--
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: Initial report on F2FS filesystem performance

2012-10-16 Thread Sooman Jeong

Tue, 16 Oct 2012 15:58:59 +0900, Namjae Jeon wrote:
>Hello.
>
>Would you share the result about random read ?
>
>Thanks.
>
>2012/10/16, Sooman Jeong <77sm...@hanyang.ac.kr>:
>>
>> This is a brief summary of our initial filesystem performance study of f2fs
>> against existing two filesystems in linux: EXT4, NILFS2, and f2fs.
>>
>>
>> * test platform
>>   i) Desktop PC : Linux 3.6.1 (f2fs patched), Intel i5-2500 @3.3GHz
>> quad-core, 8GB RAM, Transcend 16GB class 10 micro SD card
>>   ii) Galaxy-S3 : Linux 3.0.15 (f2fs ported), Android 4.0.4, DVFS turned off,
>> Transcend 16GB class 10 micro SD card
>>
>>
>> * experiment 1: buffered write(sequential and random, 4KByte write)
>> ===
>>
>> F2FS surpasses other two filesystems in both random and sequential. In
>> desktop and Galaxy S3, f2fs exhibits 2.5 and 1.6 times better performance in
>> random write against EXT4, respectively. EXT4 is standard Android
>> filesystem.
>>
>> buffered write (1GB file)
>> --
>>  Desktop PC Galaxy-S3
>> --
>>  sequential (MB/s)  random (IOPS)  sequential (MB/s)   random (IOPS) 
>>  
>> --
>>   EXT4   7.11073   6.7 1073  
>>  
>>   NILFS2 6.81462   4.0 1272  
>>  
>>   F2FS  10.62675   6.9 1682  
>>  
>> --
>>
>>
>> * experiment 2: write + fsync(sequential and random)
>> 
>>
>> F2FS surpasses other two filesystems in both random and sequential workload.
>> In desktop and Galaxy S3, f2fs exhibits 2 and 1.5 times better performance
>> in write+fsync random write against EXT4, respectively.
>>
>> write + fsync (100MB file)
>> --
>>  Desktop PC Galaxy-S3
>> --
>>  sequential (KB/s)  random (IOPS)  sequential (KB/s)   random (IOPS) 
>>  
>> --
>>   EXT4  511.8125  383.4 119
>>   NILFS2545.2112  356.7  72
>>   F2FS 1057.9240  772.3 184
>> --
>>
>> write() with fsync is to test the filesystem performance under Android
>> SQLite operation.
>>
>>
>> * experiment 3: mounting time
>> ===
>>
>> To measure the mount time, we used two different scenarios. First, we
>> mounted file system after formatting without rebooting system. Second, we
>> mounted file system after rebooting in order to ensure any data cached in
>> memory is flushed. Overall, EXT4 shows fastest mount time, and F2FS shows
>> second best performance; however, we observed that F2FS takes longest time
>> to mount right after formatting.
>>
>> mounting time with Transcend 16GB micro-SD
>> -
>>  Desktop PC Galaxy-S3
>> -
>>  1st mount afterafter rebooting   1st mount afterafter 
>> rebooting
>>  format (msec)  (msec)format (msec)  (msec)
>> -
>>   EXT411202040
>>   NILFS2 920  1013  1680  1630
>>   F2FS  1486   161  2280  1570
>> -
>>
>>
>> Sooman Jeong  ESOS Lab. Hanyang University.
>> <77sm...@hanyang.ac.kr>


As you have requested, I have attached result of read performance(iozone).

* experiment 4: read(sequential and random)


F2FS shows slightly better read performance than other two filesystems in both
sequential and random workload.

buffered read (1GB file)
--
 Desktop PC Galaxy-S3
--
 sequential (MB/s)  random (IOPS)  sequential (MB/s)   random (IOPS)  

Re: [PATCH] x86/ioapic: fix the irq_2_pin mem leak when destroy_irq

2012-10-16 Thread Yinghai Lu
On Tue, Oct 16, 2012 at 8:36 PM, Liu, Chuansheng
 wrote:
>> So we can use generic list helper function.
> Does it really need the generic list with both prev and next pointers?
> For irq_2_pin list, the next pointer seems be enough.

generic version should be always better than home grown one.
--
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 v4 4/6] perf tools: Try to find cross-built objdump path

2012-10-16 Thread Namhyung Kim
Hi Arnaldo and Irina,

On Tue, 16 Oct 2012 08:26:19 -0700, Arnaldo Carvalho de Melo wrote:
> Em Tue, Oct 16, 2012 at 02:33:38AM +0300, Irina Tirdea escreveu:
>> From: Namhyung Kim 
>
> Well, by now it is not anymore from Namhyung, but based on a previous
> patch by him, right?
>
> I'm ok with the patch, thanks for addressing my suggestions, but please
> resubmit with you as the patch author, giving credit for the original
> patch by Namhyung.
>
> Namhyung, are you ok with it? If so could I have a reviewed-by from you
> or at least an acked-by? The SOB is to be dropped, as this is not coming
> from you, but directly from Irina and as explained above, its a modified
> patch.

Sure.  Please feel free to add my

Acked-by: Namhyung Kim 

Thanks,
Namhyung

--
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] DMA: PL330: Add runtime pm support

2012-10-16 Thread Inderpal Singh
At the pl330's probe point the device is already in runtime resume state.
Hence to manage the device with runtime, the probe should do pm_runtime_put
and remove should do pm_runtime_get to balance with probe.

And in between, the device is being get/put at alloc_chan_resources and
free_chan_resources.

Signed-off-by: Inderpal Singh 
---
This patch is based on slave-dma's next branch and on top
of the clean up patches at [1].

[1] https://lkml.org/lkml/2012/10/5/169

 drivers/dma/pl330.c |   10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 2ee1538..5ae19ea 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "dmaengine.h"
 #define PL330_MAX_CHAN 8
@@ -2384,6 +2385,8 @@ static int pl330_alloc_chan_resources(struct dma_chan 
*chan)
struct dma_pl330_dmac *pdmac = pch->dmac;
unsigned long flags;
 
+   pm_runtime_get_sync(pdmac->ddma.dev);
+
spin_lock_irqsave(&pch->lock, flags);
 
dma_cookie_init(chan);
@@ -2392,6 +2395,7 @@ static int pl330_alloc_chan_resources(struct dma_chan 
*chan)
pch->pl330_chid = pl330_request_channel(&pdmac->pif);
if (!pch->pl330_chid) {
spin_unlock_irqrestore(&pch->lock, flags);
+   pm_runtime_put(pdmac->ddma.dev);
return -ENOMEM;
}
 
@@ -2470,6 +2474,8 @@ static void pl330_free_chan_resources(struct dma_chan 
*chan)
list_splice_tail_init(&pch->work_list, &pch->dmac->desc_pool);
 
spin_unlock_irqrestore(&pch->lock, flags);
+
+   pm_runtime_put(pch->dmac->ddma.dev);
 }
 
 static enum dma_status
@@ -2974,6 +2980,8 @@ pl330_probe(struct amba_device *adev, const struct 
amba_id *id)
pi->pcfg.data_bus_width / 8, pi->pcfg.num_chan,
pi->pcfg.num_peri, pi->pcfg.num_events);
 
+   pm_runtime_put(pd->dev);
+
return 0;
 
 probe_err5:
@@ -3017,6 +3025,8 @@ static int __devexit pl330_remove(struct amba_device 
*adev)
return -EBUSY;
}
 
+   pm_runtime_get(pdmac->ddma.dev);
+
dma_async_device_unregister(&pdmac->ddma);
 
amba_set_drvdata(adev, NULL);
-- 
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: [patch for-3.7] mm, mempolicy: fix printing stack contents in numa_maps

2012-10-16 Thread Dave Jones
On Tue, Oct 16, 2012 at 05:31:23PM -0700, David Rientjes wrote:

 > -pol = get_vma_policy(proc_priv->task, vma, vma->vm_start);
 > +task_lock(task);
 > +pol = get_vma_policy(task, vma, vma->vm_start);
 >  mpol_to_str(buffer, sizeof(buffer), pol, 0);
 >  mpol_cond_put(pol);
 > +task_unlock(task);

This seems to cause some fallout for me..

BUG: sleeping function called from invalid context at kernel/mutex.c:269
in_atomic(): 1, irqs_disabled(): 0, pid: 8558, name: trinity-child2
3 locks on stack by trinity-child2/8558:
 #0: held: (&p->lock){+.+.+.}, instance: 88010c9a00b0, at: 
[] seq_lseek+0x3f/0x120
 #1: held: (&mm->mmap_sem){++}, instance: 88013956f7c8, at: 
[] m_start+0xa7/0x190
 #2: held: (&(&p->alloc_lock)->rlock){+.+...}, instance: 88011fc64f30, 
at: [] show_numa_map+0x14f/0x610
Pid: 8558, comm: trinity-child2 Not tainted 3.7.0-rc1+ #32
Call Trace:
 [] __might_sleep+0x14c/0x200
 [] mutex_lock_nested+0x2e/0x50
 [] mpol_shared_policy_lookup+0x33/0x90
 [] shmem_get_policy+0x33/0x40
 [] get_vma_policy+0x3a/0x90
 [] show_numa_map+0x163/0x610
 [] ? pid_maps_open+0x20/0x20
 [] ? pagemap_hugetlb_range+0xf0/0xf0
 [] show_pid_numa_map+0x13/0x20
 [] traverse+0xf2/0x230
 [] seq_lseek+0xab/0x120
 [] sys_lseek+0x7b/0xb0
 [] tracesys+0xe1/0xe6


same problem, different syscall..


BUG: sleeping function called from invalid context at kernel/mutex.c:269
in_atomic(): 1, irqs_disabled(): 0, pid: 21996, name: trinity-child3
3 locks on stack by trinity-child3/21996:
 #0: held: (&p->lock){+.+.+.}, instance: 88008d712c08, at: 
[] seq_read+0x3d/0x3e0
 #1: held: (&mm->mmap_sem){++}, instance: 88013956f7c8, at: 
[] m_start+0xa7/0x190
 #2: held: (&(&p->alloc_lock)->rlock){+.+...}, instance: 88011fc64f30, 
at: [] show_numa_map+0x14f/0x610
Pid: 21996, comm: trinity-child3 Not tainted 3.7.0-rc1+ #32
Call Trace:
 [] __might_sleep+0x14c/0x200
 [] mutex_lock_nested+0x2e/0x50
 [] mpol_shared_policy_lookup+0x33/0x90
 [] shmem_get_policy+0x33/0x40
 [] get_vma_policy+0x3a/0x90
 [] show_numa_map+0x163/0x610
 [] ? pid_maps_open+0x20/0x20
 [] ? pagemap_hugetlb_range+0xf0/0xf0
 [] show_pid_numa_map+0x13/0x20
 [] traverse+0xf2/0x230
 [] seq_read+0x34b/0x3e0
 [] ? seq_lseek+0x120/0x120
 [] do_loop_readv_writev+0x5a/0x90
 [] do_readv_writev+0x1c1/0x1e0
 [] ? get_parent_ip+0x11/0x50
 [] vfs_readv+0x35/0x60
 [] sys_preadv+0xc2/0xe0
 [] tracesys+0xe1/0xe6


--
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 1/3] mmc: esdhc: enable polling to detect card by itself

2012-10-16 Thread Yong Ding
Shawn,
Thanks for your comment. And sorry for my so late due to illness:-)
SDHCI_QUIRK_BROKEN_CARD_DETECTION is used for notifying we don't use the host 
internal card detection method so that we don't need enable/disable those 
relevant interrupt bits of host(sdhci_set_card_detection in sdhci.c). 
And as I double-checked the latest kernel code, actually sdhci-esdhc-imx sets 
this flag by default, and then will clear it only when the detection type is 
ESDHC_CD_CONTROLLER. So this aligns with my understanding. 
What I want to do is that 1st we shall set MMC_CAP_NEEDS_POLL by our host 
driver itself and 2nd remove the improper logic in sdhci_add_host() . How do u 
think? Thanks.


From: Shawn Guo [shawn@linaro.org]
Sent: Sunday, October 07, 2012 22:06
To: Yong Ding
Cc: Chris Ball; Anton Vorontsov; Marek Szyprowski; Wolfram Sang; Daniel Drake; 
Sascha Hauer; Wilson Callan; Ben Dooks; Zhangfei Gao; Kevin Liu; Jialing Fu; 
linux-...@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] mmc: esdhc: enable polling to detect card by itself

On Fri, Sep 28, 2012 at 06:28:31PM +0800, yongd wrote:
> In the current code logic, sdhci_add_host() will enable the polling
> method (set MMC_CAP_NEEDS_POLL) for a removable card (MMC_CAP_
> NONREMOVABLE is not set) whose host's internal card detection method
> is disabled for some reason (SDHCI_QUIRK_BROKEN_CARD_DETECTION is set).
>
> However, this is improper since we can have some other card detection
> methods besides host internal card detection and polling method. For
> example, if the card detection type is ESDHC_CD_GPIO (external gpio pin
> for CD), we will keep SDHCI_QUIRK_BROKEN_CARD_DETECTION set. This is right.
> But, just as above said, sdhci_add_host() will also enable polling for such
> a card. This is redundant.
>
At least for sdhci-esdhc-imx, SDHCI_QUIRK_BROKEN_CARD_DETECTION will
be set only when neither ESDHC_CD_GPIO nor ESDHC_CD_CONTROLLER works.

Shawn

> On the other hand, for the card with ESDHC_CD_NONE detection type(no CD, 
> neither
> controller nor gpio, so use polling), we currently rely on sdhci_add_host() to
> enable polling for us.
>
> Here proposed a solution for such an embarrassing case. 1st, this patch will
> de-couple polling enabling with sdhci_add_host() by doing this in host driver
> itself, just as some other vendors. 2nd, one more patch will remove such 
> improper
> MMC_CAP_NEEDS_POLL enabling in sdhci_add_host().
>
> Change-Id: Ia7525009d8fd188e3f0169f225e4a76ff9e94b47
> Signed-off-by: yongd 
> ---
>  drivers/mmc/host/sdhci-esdhc-imx.c |1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
> b/drivers/mmc/host/sdhci-esdhc-imx.c
> index e23f813..f70079c 100644
> --- a/drivers/mmc/host/sdhci-esdhc-imx.c
> +++ b/drivers/mmc/host/sdhci-esdhc-imx.c
> @@ -569,6 +569,7 @@ static int __devinit sdhci_esdhc_imx_probe(struct 
> platform_device *pdev)
>   break;
>
>   case ESDHC_CD_NONE:
> + host->mmc->caps = MMC_CAP_NEEDS_POLL;
>   break;
>   }
>
> --
> 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/


lots of suspicious RCU traces

2012-10-16 Thread Dave Jones
I just triggered this while fuzz testing. All traces happened
in quick succession.

Dave

===
[ INFO: suspicious RCU usage. ]
3.7.0-rc1+ #31 Not tainted
---
include/linux/rcupdate.h:738 rcu_read_lock() used illegally while idle!

other info that might help us debug this:


RCU used illegally from idle CPU!
rcu_scheduler_active = 1, debug_locks = 1
RCU used illegally from extended quiescent state!
2 locks on stack by trinity-main/9791:
 #0: held: (&(&sighand->siglock)->rlock){-.-.-.}, instance: 
8801435dce20, at: [] ptrace_notify+0x53/0x90
 #1: blocked:  (rcu_read_lock){.+.+..}, instance: 81c34e80, at: 
[] __task_pid_nr_ns+0x5/0x1a0

stack backtrace:
Pid: 9791, comm: trinity-main Not tainted 3.7.0-rc1+ #31
Call Trace:
 [] lockdep_rcu_suspicious+0xe2/0x130
 [] __task_pid_nr_ns+0x165/0x1a0
 [] ? __task_pid_nr_ns+0x5/0x1a0
 [] ptrace_do_notify+0x5f/0xb0
 [] ptrace_notify+0x64/0x90
 [] tracehook_report_syscall_exit+0x36/0xb0
 [] ? finish_task_switch+0x7c/0x120
 [] ? int_very_careful+0x5/0xd
 [] syscall_trace_leave+0x79/0x150
 [] int_check_syscall_exit_work+0x34/0x3d

===
[ INFO: suspicious RCU usage. ]
3.7.0-rc1+ #31 Not tainted
---
include/linux/rcupdate.h:759 rcu_read_unlock() used illegally while idle!

other info that might help us debug this:


RCU used illegally from idle CPU!
rcu_scheduler_active = 1, debug_locks = 1
RCU used illegally from extended quiescent state!
2 locks on stack by trinity-main/9791:
 #0: held: (&(&sighand->siglock)->rlock){-.-.-.}, instance: 
8801435dce20, at: [] ptrace_notify+0x53/0x90
 #1: blocked:  (rcu_read_lock){.+.+..}, instance: 81c34e80, at: 
[] __task_pid_nr_ns+0x5/0x1a0

stack backtrace:
Pid: 9791, comm: trinity-main Not tainted 3.7.0-rc1+ #31
Call Trace:
 [] lockdep_rcu_suspicious+0xe2/0x130
 [] __task_pid_nr_ns+0x131/0x1a0
 [] ? __task_pid_nr_ns+0x5/0x1a0
 [] ptrace_do_notify+0x5f/0xb0
 [] ptrace_notify+0x64/0x90
 [] tracehook_report_syscall_exit+0x36/0xb0
 [] ? finish_task_switch+0x7c/0x120
 [] ? int_very_careful+0x5/0xd
 [] syscall_trace_leave+0x79/0x150
 [] int_check_syscall_exit_work+0x34/0x3d

===
[ INFO: suspicious RCU usage. ]
3.7.0-rc1+ #31 Not tainted
---
include/linux/rcupdate.h:738 rcu_read_lock() used illegally while idle!

other info that might help us debug this:


RCU used illegally from idle CPU!
rcu_scheduler_active = 1, debug_locks = 1
RCU used illegally from extended quiescent state!
3 locks on stack by migration/2/24:
 #0: held: (&rq->lock){-.-.-.}, instance: 8801481d4a98, at: 
[] active_load_balance_cpu_stop+0x328/0x490
 #1: held: (&rq->lock/1){..-.-.}, instance: 8801483d4a98, at: 
[] active_load_balance_cpu_stop+0x339/0x490
 #2: blocked:  (rcu_read_lock){.+.+..}, instance: 81c34e80, at: 
[] active_load_balance_cpu_stop+0xf4/0x490

stack backtrace:
Pid: 24, comm: migration/2 Not tainted 3.7.0-rc1+ #31
Call Trace:
 [] lockdep_rcu_suspicious+0xe2/0x130
 [] active_load_balance_cpu_stop+0x3ac/0x490
 [] ? active_load_balance_cpu_stop+0xf4/0x490
 [] ? cpu_stopper_thread+0xb3/0x1d0
 [] ? put_lock_stats.isra.25+0xe/0x40
 [] ? _raw_spin_unlock_irq+0x30/0x80
 [] ? get_parent_ip+0x11/0x50
 [] ? get_parent_ip+0x11/0x50
 [] ? select_task_rq_fair+0xad0/0xad0
 [] cpu_stopper_thread+0xdb/0x1d0
 [] ? sub_preempt_count+0x79/0xd0
 [] ? __schedule+0x499/0xa40
 [] ? cpu_stop_queue_work+0x80/0x80
 [] kthread+0xed/0x100
 [] ? put_lock_stats.isra.25+0xe/0x40
 [] ? kthread_create_on_node+0x160/0x160
 [] ret_from_fork+0x7c/0xb0
 [] ? kthread_create_on_node+0x160/0x160

===
[ INFO: suspicious RCU usage. ]
3.7.0-rc1+ #31 Not tainted
---
kernel/sched/fair.c:4538 suspicious rcu_dereference_check() usage!

other info that might help us debug this:


RCU used illegally from idle CPU!
rcu_scheduler_active = 1, debug_locks = 1
RCU used illegally from extended quiescent state!
3 locks on stack by migration/2/24:
 #0: held: (&rq->lock){-.-.-.}, instance: 8801481d4a98, at: 
[] active_load_balance_cpu_stop+0x328/0x490
 #1: held: (&rq->lock/1){..-.-.}, instance: 8801483d4a98, at: 
[] active_load_balance_cpu_stop+0x339/0x490
 #2: blocked:  (rcu_read_lock){.+.+..}, instance: 81c34e80, at: 
[] active_load_balance_cpu_stop+0xf4/0x490

stack backtrace:
Pid: 24, comm: migration/2 Not tainted 3.7.0-rc1+ #31
Call Trace:
 [] lockdep_rcu_suspicious+0xe2/0x130
 [] active_load_balance_cpu_stop+0x435/0x490
 [] ? active_load_balance_cpu_stop+0xf4/0x490
 [] ? cpu_stopper_thread+0xb3/0x1d0
 [] ? put_lock_stats.isra.25+0xe/0x40
 [] ? _raw_spin_unlock_irq+0x30/0x80
 [] ? get_parent_ip+0x11/0x50
 [] ? get_parent_ip+0x11/0x50
 [] ? select_task_rq_fair+0xad0/0xad0
 [] cpu_stopper_thread+0xdb/0x1d0
 [] ? sub_preempt_count+0x79/0xd0
 [] ? __schedule+0x499/0xa40
 [] ? cpu_stop_queue_work+0x80/0x80
 [] kthr

RE: [PATCH 11/16] f2fs: add inode operations for special inodes

2012-10-16 Thread Jaegeuk Kim
> 2012-10-16 (화), 16:14 +, Arnd Bergmann:
> > On Tuesday 16 October 2012, Jaegeuk Kim wrote:
> > > Thank you for a lot of points to be addressed. :)
> > > Maybe it's time to summarize them.
> > > Please let me know what I misunderstood.
> > >
> > > [In v2]
> > > - Extension list
> > >   : Mkfs supports configuring extensions by user, and that information
> > > will be stored in the superblock. In order to reduce the cleaning 
> > > overhead,
> > > f2fs supports an additional interface, ioctl, likewise ext4.
> >
> > That is what I suggested but actually Dave Chinner is the person that you
> > need to listen to rather than me in this regard. Using an extended attribute
> > in the root node would be more appropriate to configure this than an ioctl.
> >
> > > - The number of active logs
> > >   : No change will be done in on-disk layout (i.e., max 6 logs).
> > > Instead, f2fs supports changing the number with a mount option.
> > > Currently, I think 4, 5, and 6 would be enough.
> >
> > Right, that would be the minimum that I would ask for. If it is relatively
> > easy to support more than six logs in the file format without actually
> > implementing them in the code, you might want to support up to 16, just
> > to be future-proof.
> 
> Ok, got it.
> 
> >
> > For the lower bound, being able to support as little as 2 logs for
> > cheap hardware would be nice, but 4 logs is the important one.
> >
> > 5 logs is probably not all that important, as long as you have the
> > choice between 4 and 6. If you implement three different ways, I
> > would prefer have the choice of 2/4/6 over 4/5/6 logs.
> 
> Ok, I'll try, but in the case of 2 logs, it may need to change recovery
> routines.
> 
> >
> > > - Section size
> > >   : Mkfs supports multiples of segments for a section, not power-of-two.
> >
> > Right.
> >
> > > [Future optimization]
> > > - Data separation
> > >   : file access pattern, and else?
> >
> >  : Investigate the option to make large files erase block indirect rather 
> > than
> >part of the normal logs
> >
> > There is one more more point that I have not mentioned before, which is the
> > alignment of write requests. As far as I can tell, you try to group writes
> > as much as possible, but the alignment and the minimum size is still just
> > 4 KB.
> 
> Yes.
> 
> > I fear that this might not be good enough for a lot of cases when
> > the page sizes grow and there is no sufficient amount of nonvolatile
> > write cache in the device. I wonder whether there is something that can
> > be done to ensure we always write with a minimum alignment, and pad
> > out the data with zeroes if necessary in order to avoid getting into
> > garbage collection on devices that can't handle sub-page writes.
> 
> You're very familiar with flash. :)
> Yes, as the page size grows, the sub-page write issue is one of the
> most critical problems.
> I also thought this before, but I have not made a conclusion until now.
> Because, I don't know how to deal with this in other companies, but,
> I've seen that so many firmware developers in samsung have tried to
> reduce this overhead by adapting many schemes.
> I guess very cautiously that other companies also handle this well.
> Therefore, I keep a question whether file system should care about
> this perfectly or not.
> 
> Thanks,
> 
> >
> > Arnd
> 

As discussed with Dave, I propose the following items.

[In v2]
- Extension list
   : Mkfs supports configuring extensions by user, and that information
 will be stored in the superblock.
 I'll add a mount option to enable/disable using the extension list.
 Instead, f2fs supports xattr to give a hint to any files.
 After supporting this by VFS, it'll be removed.
- The number of active logs
  : For compatibility, on-disk layout supports max 16 logs.
Instead, f2fs supports configuring the number of active logs that
will be used by a mount option.
The option supports 2, 4, and 6 logs.
- Section size
  : Mkfs supports multiples of segments for a section, not power-of-two.

[Future optimization]
- Data separation
  : file access pattern
  : Investigate the option to make large files erase block indirect rather than
   part of the normal logs
  : sub-page write avoidance

Thanks,

> --
> Jaegeuk Kim
> Samsung

--
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 3/6] Input: da9052_tsi.c: Fix interrupt handling

2012-10-16 Thread Fabio Estevam
Hi Dmitry,

On Thu, Oct 4, 2012 at 1:21 AM, Fabio Estevam  wrote:
> From: Fabio Estevam 
>
> Currently da9062_tsi does not probe and it fails as follows:
>
> da9052 1-0048: Unable to determine device interrupts
>
> Use the new da9052 irq functions and allow the driver to probe and operate
> correctly.
>
> Tested on mx53qsb board using 'evtest' tool.
>
> Cc: Dmitry Torokhov 
> Cc: 
> Signed-off-by: Fabio Estevam 

Does this look good for you?

Regards,

Fabio Estevam
--
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 PATCH v1 1/3] mm: teach mm by current context info to not do I/O during memory allocation

2012-10-16 Thread Ming Lei
On Wed, Oct 17, 2012 at 4:19 AM, Andrew Morton
 wrote:
>
> The patch seems reasonable to me.  I'd like to see some examples of
> these resume-time callsite which are performing the GFP_KERNEL
> allocations, please.  You have found some kernel bugs, so those should
> be fully described.

OK, there are two examples of GFP_KERNEL allocation in subsystem
runtime resume path:

1), almost all devices in some pci platform
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

2), all devices in usb subsystem
usb_get_status
<-finish_port_resume
<-usb_port_resume
<-generic_resume
<-usb_resume_device
<-usb_resume_both
<-usb_runtime_resume

I also have many examples in which GFP_KERNEL allocation
is involved in runtime resume path of individual drivers.

The above two examples just show how difficult to solve the problem
by traditional way, :-)

Also as pointed by Oliver, network driver need memory allocation with
no io in iSCSI runtime resume situation too.

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/


Re: [PATCH 1/5] ata: suspend/resume callbacks should be conditionally compiled on CONFIG_PM_SLEEP

2012-10-16 Thread viresh kumar
On Tue, Oct 16, 2012 at 8:29 PM, Yuanhan Liu
 wrote:
> This will fix warnings like following when CONFIG_PM_SLEEP is not set:
>
> warning: 'xxx_suspend' defined but not used [-Wunused-function]
> warning: 'xxx_resume' defined but not used [-Wunused-function]
>
> Because
> SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn)
>
> Only references the callbacks on CONFIG_PM_SLEEP (instead of CONFIG_PM).
>
> Cc: Jeff Garzik 
> Cc: Viresh Kumar 
> Cc: linux-...@vger.kernel.org
> Signed-off-by: Yuanhan Liu 
> Signed-off-by: Fengguang Wu 
> ---
>  drivers/ata/ahci_platform.c  |2 +-
>  drivers/ata/pata_arasan_cf.c |2 +-

For pata_arasan:

Acked-by: Viresh Kumar 

--
viresh
--
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] Make uapi/linux/irqnr.h non-empty

2012-10-16 Thread viresh kumar
On Wed, Oct 17, 2012 at 7:33 AM, Linus Torvalds
 wrote:

> Some of the empty files seem pointless. The
>
>   arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h
>
> file, for example, has always been empty, and does not seem to be actually 
> used.
>
> Hmm? I added a few more people to the cc list.

Shocked :)
I never realized these files were added by my commit and it never got caught in
reviews :(

Probably because git log --stat or git show (stat part) doesn't show
files with zero
changes. Probably need to fix that too?

@Arnd: Can you please apply following patch to fix SPEAr's issues
point out by Linus?

x---x

From: Viresh Kumar 
Date: Wed, 17 Oct 2012 08:58:08 +0530
Subject: [PATCH] ARM: SPEAr: Remove unused empty files

Few empty files (spear1310_misc_regs.h and spear1340_misc_regs.h) are created by
commit:

commit b31e23726bb9d6cd8848fc539b23330769830110
Author: Viresh Kumar 
Date:   Thu Apr 19 22:23:13 2012 +0530

SPEAr13xx: Add header files

Don't know how they got added, obviously my fault :)
But nobody could even catch them in reviews.

Remove them.

Signed-off-by: Viresh Kumar 
---
 0 files changed
 delete mode 100644 arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h
 delete mode 100644 arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h

diff --git a/arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h
b/arch/arm/mach-spear13xx/include/mach/spear1310_misc_regs.h
deleted file mode 100644
index e69de29..000
diff --git a/arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h
b/arch/arm/mach-spear13xx/include/mach/spear1340_misc_regs.h
deleted file mode 100644
index e69de29..000
--
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] x86/ioapic: fix the irq_2_pin mem leak when destroy_irq

2012-10-16 Thread Liu, Chuansheng
> -Original Message-
> From: yhlu.ker...@gmail.com [mailto:yhlu.ker...@gmail.com] On Behalf Of
> Yinghai Lu
> Sent: Wednesday, October 17, 2012 10:03 AM
> To: Liu, Chuansheng
> Cc: t...@linutronix.de; mi...@redhat.com; Siddha, Suresh B;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] x86/ioapic: fix the irq_2_pin mem leak when destroy_irq
> 
> On Wed, Oct 17, 2012 at 3:11 AM, Chuansheng Liu
>  wrote:
> >
> > When destroying the irq, before free cfg, need to check
> > cfg->irq_2_pin and free it when it is not NULL.
> >
> > Signed-off-by: liu chuansheng 
> > ---
> 
> i had that in another patch...
> 
> https://lkml.org/lkml/2012/2/23/574
Sorry to not know that.
> 
> 
> Subject   [PATCH 01/13] x86, irq: Convert irq_2_pin list to generic list
> Date  Thu, 23 Feb 2012 19:48:47 -0800
> 
> So we can use generic list helper function.
Does it really need the generic list with both prev and next pointers?
For irq_2_pin list, the next pointer seems be enough.

> 
> Also make free_irq_cfg() free irq_2_pin list.
> 
> 
> http://git.kernel.org/?p=linux/kernel/git/yinghai/linux-yinghai.git;a=commitdiff;
> h=4010f4dbd1b172e3080d3e6c459a58c4b575f081
> 
> Yinghai
--
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] drivers/tty: Folding Android's keyreset driver in sysRQ

2012-10-16 Thread Arve Hjønnevåg
On Fri, Oct 5, 2012 at 12:48 PM, Mathieu Poirier
 wrote:
> On 12-10-05 12:16 PM, Dmitry Torokhov wrote:
>> On Fri, Oct 05, 2012 at 11:59:29AM -0600, mathieu.poir...@linaro.org wrote:
>>> From: "Mathieu J. Poirier" 
>>>
>>> Andrew,
>>>
>>> After requesting a number of changes that, to my understanding
>>> have been implemented, I have not been able to get the attention
>>> of the subsystem maintainer on this patch.
>>>
>>> If there are still issues, I'm open to making changes but I want
>>> to make sure it doesn't get forgotten.  If there no objections,
>>> would you consider queuint it ?
>>
>> Mathieu,
>>
>> I have the same objection as before: using platform device solely for
>> the purpose of passing some data from board code to the driver. Surely
>> there are other ways of passing this bit of data... What about, for
>> example, making it an empty weak symbol so that board code could
>> override it with strong one?
>
> Thanks for the comments - I will implement a weak function in the
> keyreset driver.
>

A weak symbol does not work. A single kernel can support multiple
devices that have unique reset key combinations.

-- 
Arve Hjønnevåg
--
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] Fix a hard coding style when determining if a device is a container.

2012-10-16 Thread Tang Chen

Hi,

Would anyone help to review this patch, and give some comments, please ?

Thanks. :)

On 10/12/2012 08:31 PM, Tang Chen wrote:

"ACPI0004","PNP0A05" and "PNP0A06" are all defined in array
container_device_ids[], so use it, but not the hard coding style.

Also, introduce a new api is_container_device() to determine if a
device is a container device.

Signed-off-by: Tang Chen
Signed-off-by: Yasuaki Ishimatsu
---
  drivers/acpi/container.c |   17 ++---
  1 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/container.c b/drivers/acpi/container.c
index 1f9f7d7..ffd76ee 100644
--- a/drivers/acpi/container.c
+++ b/drivers/acpi/container.c
@@ -92,6 +92,19 @@ static int is_device_present(acpi_handle handle)
return ((sta&  ACPI_STA_DEVICE_PRESENT) == ACPI_STA_DEVICE_PRESENT);
  }

+static int is_container_device(const char *hid)
+{
+   const struct acpi_device_id *container_id;
+
+   for (container_id = container_device_ids;
+container_id->id[0]; container_id++) {
+   if (!strcmp((char *)container_id->id, hid))
+   return 1;
+   }
+
+   return 0;
+}
+
  /***/
  static int acpi_container_add(struct acpi_device *device)
  {
@@ -232,10 +245,8 @@ container_walk_namespace_cb(acpi_handle handle,
goto end;
}

-   if (strcmp(hid, "ACPI0004")&&  strcmp(hid, "PNP0A05")&&
-   strcmp(hid, "PNP0A06")) {
+   if (!is_container_device(hid))
goto end;
-   }

switch (*action) {
case INSTALL_NOTIFY_HANDLER:


--
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 RFT] regulator: vexpress: Add missing n_voltages setting

2012-10-16 Thread Axel Lin
Signed-off-by: Axel Lin 
---
Hi Pawel,
I don't have a chance to compile test this patch because I could not
find VEXPRESS_CONFIG in current tree.
Can you help testing this patch?

Thanks,
Axel
 drivers/regulator/vexpress.c |8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/vexpress.c b/drivers/regulator/vexpress.c
index 1702945..94a8cb9 100644
--- a/drivers/regulator/vexpress.c
+++ b/drivers/regulator/vexpress.c
@@ -86,10 +86,14 @@ static int vexpress_regulator_probe(struct platform_device 
*pdev)
}
 
init_data->constraints.apply_uV = 0;
-   if (init_data->constraints.min_uV && init_data->constraints.max_uV)
+   if (init_data->constraints.min_uV && init_data->constraints.max_uV) {
reg->desc.ops = &vexpress_regulator_ops;
-   else
+   reg->desc.n_voltages = init_data->constraints.max_uV -
+  init_data->constraints.min_uV + 1;
+   } else {
reg->desc.ops = &vexpress_regulator_ops_ro;
+   reg->desc.n_voltages = 1;
+   }
 
config.dev = &pdev->dev;
config.init_data = init_data;
-- 
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/1] Update acpi_root_bridge_list in container hotplug path.

2012-10-16 Thread Tang Chen
Hi Yinghai,

List acpi_root_bridge_list is only updated when kernel is booting,
or in _handle_hotplug_event_root() when handling ACPI_NOTIFY_DEVICE_CHECK
event on a pci root bridge device. But when we hotplug a container, which
contains one or more pci root bridges, container_notify_cb() will be
called but not _handle_hotplug_event_root(). As a result,
acpi_root_bridge_list won't be updated.

This patch makes the following api and struct public in pci_root_hp.h,
struct acpi_root_bridge;
add_acpi_root_bridge()
remove_acpi_root_bridge()
acpi_root_handle_to_bridge()
and call add_acpi_root_bridge() in acpi_bus_check_add() and call
remove_acpi_root_bridge() in acpi_bus_remove().

This patch is based on Lu Yinghai's git tree branch for-pci-split-pci-root-hp-2.

Signed-off-by: Tang Chen 
---
 drivers/acpi/pci_root_hp.c |   20 ++--
 drivers/acpi/scan.c|   18 --
 include/acpi/pci_root_hp.h |   13 +
 3 files changed, 35 insertions(+), 16 deletions(-)
 create mode 100644 include/acpi/pci_root_hp.h

diff --git a/drivers/acpi/pci_root_hp.c b/drivers/acpi/pci_root_hp.c
index 01e71f6..6381a26 100644
--- a/drivers/acpi/pci_root_hp.c
+++ b/drivers/acpi/pci_root_hp.c
@@ -31,7 +31,7 @@ static const struct acpi_device_id root_device_ids[] = {
 
 #define ACPI_STA_FUNCTIONING   (0x0008)
 
-static struct acpi_root_bridge *acpi_root_handle_to_bridge(acpi_handle handle)
+struct acpi_root_bridge *acpi_root_handle_to_bridge(acpi_handle handle)
 {
struct acpi_root_bridge *bridge;
 
@@ -43,7 +43,7 @@ static struct acpi_root_bridge 
*acpi_root_handle_to_bridge(acpi_handle handle)
 }
 
 /* allocate and initialize host bridge data structure */
-static void add_acpi_root_bridge(acpi_handle handle)
+void add_acpi_root_bridge(acpi_handle handle)
 {
struct acpi_root_bridge *bridge;
acpi_handle dummy_handle;
@@ -79,7 +79,7 @@ static void add_acpi_root_bridge(acpi_handle handle)
list_add(&bridge->list, &acpi_root_bridge_list);
 }
 
-static void remove_acpi_root_bridge(struct acpi_root_bridge *bridge)
+void remove_acpi_root_bridge(struct acpi_root_bridge *bridge)
 {
list_del(&bridge->list);
kfree(bridge);
@@ -172,10 +172,8 @@ static void handle_root_bridge_removal(acpi_handle handle,
u32 flags = 0;
struct acpi_device *device;
 
-   if (bridge) {
+   if (bridge)
flags = bridge->flags;
-   remove_acpi_root_bridge(bridge);
-   }
 
if (!acpi_bus_get_device(handle, &device)) {
int ret_val;
@@ -223,10 +221,8 @@ static void _handle_hotplug_event_root(struct work_struct 
*work)
/* bus enumerate */
printk(KERN_DEBUG "%s: Bus check notify on %s\n", __func__,
 objname);
-   if (!bridge) {
+   if (!bridge)
handle_root_bridge_insertion(handle);
-   add_acpi_root_bridge(handle);
-   }
 
break;
 
@@ -234,10 +230,8 @@ static void _handle_hotplug_event_root(struct work_struct 
*work)
/* device check */
printk(KERN_DEBUG "%s: Device check notify on %s\n", __func__,
 objname);
-   if (!bridge) {
+   if (!bridge)
handle_root_bridge_insertion(handle);
-   add_acpi_root_bridge(handle);
-   }
break;
 
case ACPI_NOTIFY_EJECT_REQUEST:
@@ -304,8 +298,6 @@ find_root_bridges(acpi_handle handle, u32 lvl, void 
*context, void **rv)
printk(KERN_DEBUG "acpi root: %s notify handler is installed\n",
 objname);
 
-   add_acpi_root_bridge(handle);
-
return AE_OK;
 }
 
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 6ca2eaf..c258064 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -12,6 +12,7 @@
 #include 
 
 #include 
+#include 
 
 #include "internal.h"
 
@@ -1265,8 +1266,17 @@ int acpi_bus_remove(struct acpi_device *dev, int 
rmdevice)
dev->removal_type = ACPI_BUS_REMOVAL_EJECT;
device_release_driver(&dev->dev);
 
-   if (rmdevice)
+   if (rmdevice) {
+   if (acpi_is_root_bridge(dev->handle)) {
+   struct acpi_root_bridge *bridge;
+
+   bridge = acpi_root_handle_to_bridge(dev->handle);
+   if (bridge)
+   remove_acpi_root_bridge(bridge);
+   }
+
acpi_device_unregister(dev, ACPI_BUS_REMOVAL_EJECT);
+   }
 
return 0;
 }
@@ -1448,9 +1458,13 @@ static acpi_status acpi_bus_check_add(acpi_handle 
handle, u32 lvl,
 */
device = NULL;
acpi_bus_get_device(handle, &device);
-   if (ops->acpi_op_add && !device)
+   if (ops->acpi_op_add && !device) {
acpi_add_single

RE: [PATCH 11/16] f2fs: add inode operations for special inodes

2012-10-16 Thread Jaegeuk Kim
> On Wed, Oct 17, 2012 at 07:30:21AM +0900, Jaegeuk Kim wrote:
> > > > > OTOH, I think xattr itself is for users, not for communicating
> > > > > between file system and users.
> > > >
> > > > No, you are mistaken in that point, as Dave explained.
> > >
> > > e.g. selinux, IMA, ACLs, capabilities, etc all communicate
> > > information that the kernel uses for access control. That's why
> > > xattrs have different namespaces like "system", "security" and
> > > "user". Only user attributes are truly for user data
> > > - the rest are for communicating information to the kernel
> > >
> >
> > I agree that "system" is used by kernel.
> > How about the file system view?
> 
> Not sure what you mean - the filesystem woul dsimply read the xattrs
> in the system namespace as it needs, just like the other subsystems
> like selinux or IMA do.
> 
> > Would you explain what file systems retrieve xattrs and use
> > them with their own purpose?
> 
> I think cachefs users a "CacheFiles.cache" namespace for storing
> information it needs in xattrs. ecryptfs stores crypto metadata in
> xattrs in the lower filesytem. NFSv4 servers store junction mount
> information in xattrs.
> 
> So there are examples where filesystems use xattrs for special
> information. However, in most cases filesystems don't need xattrs
> for their own metadata primarily because that gets added to their
> own on-disk formats. IThe above are all "overlay" style filesystems
> that don't have their own on-disk formats, so need to use xattrs to
> store their per-inode metadata.
> 
> The case of access hints and allocation policies are not somethign
> that are native to any filesystem on-disk format. They are abstract
> concepts that really only the software generating/using that
> information knows about. Given we want the software that uses this
> information to be in VFS, it is separate from every filesystem and
> this is exactly the use case that system xattrs were intended for.
> :)

I understand. Thank you very much. :)

> 
> > Sorry, I'm not familiar with xattrs in depth.
> >
> > Unfortunately, "system" is not implemented in f2fs yet. :(
> 
> If you've already implemented the user.* namespace, then it's
> trivial to support the other namespaces - it's just prefixing the
> xattrs with the appropriate string instead of "user"
> 

Ok, I'll do right now.
Thanks, again.

> Cheers,
> 
> Dave.
> --
> Dave Chinner
> da...@fromorbit.com

--
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 v2] drivers-core: move the calling to device_pm_remove behind the calling to bus_remove_device

2012-10-16 Thread zhanglong
We hit an hang issue when removing a mmc device on Medfield Android phone by 
sysfs interface.

device_pm_remove will call pm_runtime_remove which would disable
runtime PM of the device. After that pm_runtime_get* or
pm_runtime_put* will be ignored. So if we disable the runtime PM
before device really be removed, drivers' _remove callback may
access HW even pm_runtime_get* fails. That is bad.

Consider below call sequence when removing a device:
device_del => device_pm_remove
 => class_intf->remove_dev(dev, class_intf)  => 
pm_runtime_get_sync/put_sync
 => bus_remove_device => device_release_driver => 
pm_runtime_get_sync/put_sync

remove_dev might call pm_runtime_get_sync/put_sync.
Then, generic device_release_driver also calls pm_runtime_get_sync/put_sync.
Since device_del => device_pm_remove firstly, later _get_sync wouldn't really 
wake up the device. 

I git log -p to find the patch which moves the calling to device_pm_remove 
ahead.
It's below patch:

commit  775b64d2b6ca37697de925f70799c710aab5849a
Author: Rafael J. Wysocki 
Date:   Sat Jan 12 20:40:46 2008 +0100

 PM: Acquire device locks on suspend

 This patch reorganizes the way suspend and resume notifications are
 sent to drivers.  The major changes are that now the PM core acquires
 every device semaphore before calling the methods, and calls to
 device_add() during suspends will fail, while calls to device_del()
 during suspends will block.

 It also provides a way to safely remove a suspended device with the
 help of the PM core, by using the device_pm_schedule_removal() callback
 introduced specifically for this purpose, and updates two drivers (msr
 and cpuid) that need to use it. 


As device_pm_schedule_removal is deleted by another patch, we need also revert 
other parts of the patch,
i.e. move the calling of device_pm_remove after the calling to 
bus_remove_device.

Signed-off-by: LongX Zhang 
---
 drivers/base/core.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index abea76c..150a415 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1180,7 +1180,6 @@ void device_del(struct device *dev)
if (dev->bus)
blocking_notifier_call_chain(&dev->bus->p->bus_notifier,
 BUS_NOTIFY_DEL_DEVICE, dev);
-   device_pm_remove(dev);
dpm_sysfs_remove(dev);
if (parent)
klist_del(&dev->p->knode_parent);
@@ -1205,6 +1204,7 @@ void device_del(struct device *dev)
device_remove_file(dev, &uevent_attr);
device_remove_attrs(dev);
bus_remove_device(dev);
+   device_pm_remove(dev);
driver_deferred_probe_del(dev);

/* Notify the platform of the removal, in case they
-- 
1.7.10
--
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 -tip 2/4] tracing: add a resize function for making one buffer equivalent to the other buffer

2012-10-16 Thread Steven Rostedt
On Wed, 2012-10-17 at 11:47 +0900, Hiraku Toyooka wrote:
> Steven,
> 
> I'm sorry for my late reply.
> (I was outside the office for business trip.)
> 

No problem. I'm currently on a business trip now :-)

-- Steve

--
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 v2 -tip 2/4] tracing: add a resize function for making one buffer equivalent to the other buffer

2012-10-16 Thread Hiraku Toyooka
Trace buffer size is now per-cpu, so that there are following two
patterns in resize of the buffers.

  (1) resize per-cpu buffers to same given size
  (2) resize per-cpu buffers to the other trace_array's buffer size
  for each CPU (such as preparing the max_tr which is equivalent
  to the global_trace's size)

__tracing_resize_ring_buffer() can be used for (1), and had
implemented (2) inside it for resetting the global_trace to the
original size.

(2) was also implemented in other place. So this patch assembles
them in a new function - resize_buffer_duplicate_size().

Signed-off-by: Hiraku Toyooka 
Cc: Steven Rostedt 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: linux-kernel@vger.kernel.org
---

 kernel/trace/trace.c |   58 +++---
 1 files changed, 31 insertions(+), 27 deletions(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 08acf42..d71eee1 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -3017,6 +3017,31 @@ static void set_buffer_entries(struct trace_array *tr, 
unsigned long val)
tr->data[cpu]->entries = val;
 }
 
+/* resize @tr's buffer to the size of @size_tr's entries */
+static int resize_buffer_duplicate_size(struct trace_array *tr,
+   struct trace_array *size_tr, int cpu_id)
+{
+   int cpu, ret = 0;
+
+   if (cpu_id == RING_BUFFER_ALL_CPUS) {
+   for_each_tracing_cpu(cpu) {
+   ret = ring_buffer_resize(tr->buffer,
+   size_tr->data[cpu]->entries, cpu);
+   if (ret < 0)
+   break;
+   tr->data[cpu]->entries = size_tr->data[cpu]->entries;
+   }
+   } else {
+   ret = ring_buffer_resize(tr->buffer,
+   size_tr->data[cpu_id]->entries, cpu_id);
+   if (ret == 0)
+   tr->data[cpu_id]->entries =
+   size_tr->data[cpu_id]->entries;
+   }
+
+   return ret;
+}
+
 static int __tracing_resize_ring_buffer(unsigned long size, int cpu)
 {
int ret;
@@ -3037,23 +3062,8 @@ static int __tracing_resize_ring_buffer(unsigned long 
size, int cpu)
 
ret = ring_buffer_resize(max_tr.buffer, size, cpu);
if (ret < 0) {
-   int r = 0;
-
-   if (cpu == RING_BUFFER_ALL_CPUS) {
-   int i;
-   for_each_tracing_cpu(i) {
-   r = ring_buffer_resize(global_trace.buffer,
-   global_trace.data[i]->entries,
-   i);
-   if (r < 0)
-   break;
-   }
-   } else {
-   r = ring_buffer_resize(global_trace.buffer,
-   global_trace.data[cpu]->entries,
-   cpu);
-   }
-
+   int r = resize_buffer_duplicate_size(&global_trace,
+&global_trace, cpu);
if (r < 0) {
/*
 * AARGH! We are left with different
@@ -3191,17 +3201,11 @@ static int tracing_set_tracer(const char *buf)
 
topts = create_trace_option_files(t);
if (t->use_max_tr) {
-   int cpu;
/* we need to make per cpu buffer sizes equivalent */
-   for_each_tracing_cpu(cpu) {
-   ret = ring_buffer_resize(max_tr.buffer,
-   global_trace.data[cpu]->entries,
-   cpu);
-   if (ret < 0)
-   goto out;
-   max_tr.data[cpu]->entries =
-   global_trace.data[cpu]->entries;
-   }
+   ret = resize_buffer_duplicate_size(&max_tr, &global_trace,
+  RING_BUFFER_ALL_CPUS);
+   if (ret < 0)
+   goto out;
}
 
if (t->init) {

--
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 v2 -tip 4/4] tracing: add description of snapshot to Documentation/trace/ftrace.txt

2012-10-16 Thread Hiraku Toyooka
This patch adds snapshot description in ftrace documentation.
This description includes what the snapshot is and how to use it.

Signed-off-by: Hiraku Toyooka 
Cc: Steven Rostedt 
Cc: Frederic Weisbecker 
Cc: Ingo Molnar 
Cc: Rob Landley 
Cc: linux-...@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---

 Documentation/trace/ftrace.txt |   97 
 1 files changed, 97 insertions(+), 0 deletions(-)

diff --git a/Documentation/trace/ftrace.txt b/Documentation/trace/ftrace.txt
index 6f51fed..68ac294 100644
--- a/Documentation/trace/ftrace.txt
+++ b/Documentation/trace/ftrace.txt
@@ -1842,6 +1842,103 @@ an error.
  # cat buffer_size_kb
 85
 
+Snapshot
+
+CONFIG_TRACER_SNAPSHOT makes a generic snapshot feature
+available to all non latency tracers. (Latency tracers which
+record max latency, such as "irqsoff" or "wakeup", can't use
+this feature, since those are already using the snapshot
+mechanism internally.)
+
+Snapshot preserves a trace buffer at a particular point in time
+without stopping tracing. Ftrace swaps the current buffer with a
+spare buffer, and tracing continues in the (previous) spare
+buffer.
+
+The following debugfs files in "tracing" are related to this
+feature:
+
+  snapshot:
+
+   This is used to take a snapshot and to read the output
+   of the snapshot. Echo 1 into this file to allocate a
+   spare buffer and to take a snapshot, then read the
+   snapshot from the file in the same format as "trace"
+   (described above in the section "The File System"). Both
+   reads snapshot and tracing are executable in parallel.
+   Echoing 0 erases the snapshot contents.
+
+  snapshot_allocate:
+
+   This is used to pre-allocate or free a spare buffer.
+   Echo 1 into this file to pre-allocate a spare buffer if
+   you don't want to fail in the next snapshot due to
+   memory allocation failure, or if you don't want to lose
+   older trace data while allocating buffer. Echo 0 to free
+   the spare buffer when the snapshot becomes unnecessary.
+   If you take the next snapshot again, you can reuse the
+   buffer, then just erase the snapshot contents by echoing
+   1 into the "snapshot" file, instead of freeing the
+   buffer.
+
+   Reads from this file display whether the spare buffer is
+   allocated. When current_tracer is changed, the allocated
+   spare buffer is freed. If the next tracer is one of the
+   latency tracers, this value turns into 1 and can't be
+   changed, or else the value starts with 0.
+
+
+Here is an example of using the snapshot feature.
+
+ # echo 1 > snapshot_allocate (if you want to pre-allocate the spare buffer)
+ # echo 1 > events/sched/enable
+ # echo 1 > snapshot
+ # cat snapshot
+# tracer: nop
+#
+# entries-in-buffer/entries-written: 71/71   #P:8
+#
+#  _-=> irqs-off
+# / _=> need-resched
+#| / _---=> hardirq/softirq
+#|| / _--=> preempt-depth
+#||| / delay
+#   TASK-PID   CPU#  TIMESTAMP  FUNCTION
+#  | |   |      | |
+  -0 [005] d...  2440.603828: sched_switch: 
prev_comm=swapper/5 prev_pid=0 prev_prio=120 prev_state=R ==> 
next_comm=snapshot-test-2 next_pid=2242 next_prio=120
+   sleep-2242  [005] d...  2440.603846: sched_switch: 
prev_comm=snapshot-test-2 prev_pid=2242 prev_prio=120 prev_state=R ==> 
next_comm=kworker/5:1 next_pid=60 next_prio=120
+[...]
+  -0 [002] d...  2440.707230: sched_switch: 
prev_comm=swapper/2 prev_pid=0 prev_prio=120 prev_state=R ==> 
next_comm=snapshot-test-2 next_pid=2229 next_prio=120
+ # cat trace
+# tracer: nop
+#
+# entries-in-buffer/entries-written: 77/77   #P:8
+#
+#  _-=> irqs-off
+# / _=> need-resched
+#| / _---=> hardirq/softirq
+#|| / _--=> preempt-depth
+#||| / delay
+#   TASK-PID   CPU#  TIMESTAMP  FUNCTION
+#  | |   |      | |
+  -0 [007] d...  2440.707395: sched_switch: 
prev_comm=swapper/7 prev_pid=0 prev_prio=120 prev_state=R ==> 
next_comm=snapshot-test-2 next_pid=2243 next_prio=120
+ snapshot-test-2-2229  [002] d...  2440.707438: sched_switch: 
prev_comm=snapshot-test-2 prev_pid=2229 prev_prio=120 prev_state=S ==> 
next_comm=swapper/2 next_pid=0 next_prio=120
+[...]
+
+
+If you try to use this snapshot feature when current tracer is
+one of the latency tracers, you will get the following results.
+
+ # echo wakeup > current_tracer
+ # cat snapshot_allocate
+1
+ # echo 1 > snapshot_allocate
+bash: echo: write error: Device or resource busy
+ # echo 1 > snapshot
+bash: echo: write error: Device or resource busy
+ # cat snapshot
+cat: snapshot: Device 

  1   2   3   4   5   6   7   >