Use a variable before it's declaration

2015-09-10 Thread Rock Lee
Hi, all:
Here is a snippet of linux-v3.4 which drives me crazy.
Because init_task hasn't been declared yet when init_thread_union is 
initializing. Why is there no compiling error? Any hint would be helpful.

union thread_union init_thread_union __init_task_data = 

 { INIT_THREAD_INFO(init_task) }; 

 

/* 

  * Initial task structure. 

  * 

  * All other task structs will be allocated on slabs in fork.c 

  */ 

struct task_struct init_task = INIT_TASK(init_task);


-- 
Rock Lee

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Use a variable before it's declaration

2015-09-10 Thread Bjørn Mork
Rock Lee  writes:

> Hi, all:
>   Here is a snippet of linux-v3.4 which drives me crazy.
> Because init_task hasn't been declared yet when init_thread_union is 
> initializing. Why is there no compiling error? Any hint would be helpful.
>
> union thread_union init_thread_union __init_task_data = 
>
>  { INIT_THREAD_INFO(init_task) }; 
>
>  
>
> /* 
>
>   * Initial task structure. 
>
>   * 
>
>   * All other task structs will be allocated on slabs in fork.c 
>
>   */ 
>
> struct task_struct init_task = INIT_TASK(init_task);


Because init_task is declared "extern" in linux/sched.h


Bjørn

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Use a variable before it's declaration

2015-09-10 Thread Rock Lee
On 2015/9/10 15:55, valdis.kletni...@vt.edu wrote:
> On Thu, 10 Sep 2015 15:09:42 +0800, Rock Lee said:
>
>> union thread_union init_thread_union __init_task_data =
>>
>>   { INIT_THREAD_INFO(init_task) };
>
> 'gcc -E' to see what this expands to.  All may not be as it seems. :)
>

Thanks, I used "make arch/arm/kernel/init_task.i" instead to see what 
that code expands to. It's exactly what confused me still. 
init_thread_union uses init_task before init_task's initialization.

union thread_union init_thread_union 
__attribute__((__section__(".data..init_task"))) =
  { { .task = _task, .exec_domain = _exec_domain, .flags = 
0, .preempt_count = (1 + 0x4000), .addr_limit = 0x, 
.cpu_domain = ((3) << (2*(1))) | ((3) << (2*(0))) | ((1) << (2*(2))), 
.restart_block = { .fn = do_no_restart_syscall, }, } };


struct task_struct init_task = { .state = 0, .stack = 
&(init_thread_union.thread_info), .usage = { (2) }, .flags = 0x0020, 
.prio = (100 + 40)-20, .static_prio = (100 + 40)-20, .normal_prio = (100 
+ 40)-20, .policy = 0, .cpus_allowed = (cpumask_t) { { [(((1) + (8 * 
sizeof(long)) - 1) / (8 * sizeof(long)))-1] = ( ((1) % 32) ? (1UL<<((1) 
% 32))-1 : ~0UL ) } }, .mm = ((void *)0), .active_mm = _mm, .se = { 
.group_node = { &(init_task.se.group_node), &(init_task.se.group_node) 
}, }, .rt = { .run_list = { &(init_task.rt.run_list), 
&(init_task.rt.run_list) }, .time_slice = (100 * 100 / 1000), 
.nr_cpus_allowed = 1, }, .tasks = { &(init_task.tasks), 
&(init_task.tasks) }, .ptraced = { &(init_task.ptraced), 
&(init_task.ptraced) }, .ptrace_entry = { &(init_task.ptrace_entry), 
&(init_task.ptrace_entry) }, .real_parent = _task, .parent = 
_task, .children = { &(init_task.children), &(init_task.children) 
}, .sibling = { &(init_task.sibling), &(init_task.sibling) }, 
.group_leader = _task, .real_cred = (typeof(*_cred) 
*)(_cred), .cred = (typeof(*_cred) *)(_cred), .comm = 
"swapper", .thread = { }, .fs = _fs, .files = _files, .signal 
= _signals, .sighand = _sighand, .nsproxy = _nsproxy, 
.pending = { .list = { &(init_task.pending.list), 
&(init_task.pending.list) }, .signal = {{0}}}, .blocked = {{0}}, 
.alloc_lock = (spinlock_t ) { { .rlock = { .raw_lock = { 1 }, .magic = 
0xdead4ead, .owner_cpu = -1, .owner = ((void *)-1L), } } }, 
.journal_info = ((void *)0), .cpu_timers = { { 
&(init_task.cpu_timers[0]), &(init_task.cpu_timers[0]) }, { 
&(init_task.cpu_timers[1]), &(init_task.cpu_timers[1]) }, { 
&(init_task.cpu_timers[2]), &(init_task.cpu_timers[2]) }, }, .pi_lock = 
(raw_spinlock_t) { .raw_lock = { 1 }, .magic = 0xdead4ead, .owner_cpu = 
-1, .owner = ((void *)-1L), }, .timer_slack_ns = 5, .pids = { 
[PIDTYPE_PID] = { .node = { .next = ((void *)0), .pprev = ((void *)0), 
}, .pid = _struct_pid, }, [PIDTYPE_PGID] = { .node = { .next = 
((void *)0), .pprev = ((void *)0), }, .pid = _struct_pid, }, 
[PIDTYPE_SID] = { .node = { .next = ((void *)0), .pprev = ((void *)0), 
}, .pid = _struct_pid, }, }, .thread_group = { 
&(init_task.thread_group), &(init_task.thread_group) }, };

-- 
Rock Lee

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Use a variable before it's declaration

2015-09-10 Thread Rock Lee
> Sure.  That's a completely different issue. But this works:
>
> extern int b;
> int *a = 
> int b = 20;
>
> int main(void)
> {
>   return 0;
> }
>
> and that's what the code you refer do does.

Yes, that make sense, thanks very much :-)
-- 
Rock Lee

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Use a variable before it's declaration

2015-09-10 Thread Bjørn Mork
Rock Lee  writes:

>> Rock Lee  writes:
>>
>>> Hi, all:
>>> Here is a snippet of linux-v3.4 which drives me crazy.
>>> Because init_task hasn't been declared yet when init_thread_union is
>>> initializing. Why is there no compiling error? Any hint would be helpful.
>>>
>>> union thread_union init_thread_union __init_task_data =
>>>
>>>   { INIT_THREAD_INFO(init_task) };
>>>
>>>
>>>
>>> /*
>>>
>>>* Initial task structure.
>>>
>>>*
>>>
>>>* All other task structs will be allocated on slabs in fork.c
>>>
>>>*/
>>>
>>> struct task_struct init_task = INIT_TASK(init_task);
>>
>>
>> Because init_task is declared "extern" in linux/sched.h
>>
>>
>> Bjørn
>
> I do something like that:
>
> extern int b;
> int a = b + 10;
> int b = 20;
>
> int main(void)
> {
>   return 0;
> }
>
> No doubt, compiling error.

Sure.  That's a completely different issue. But this works:

extern int b;
int *a = 
int b = 20;

int main(void)
{
return 0;
}

and that's what the code you refer do does.



Bjørn


___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Set the ACPI=on on the cmdline, and the OS can not boot.

2015-09-10 Thread tianlilai
 Hi,Everyone,I have a problem as follow:

 When I set the ACPI=on on the cmdline,and the OS can not boot(If set ACPI=off, 
The system is OK). The attachmemt file is the booting log. Would help me 
slove this ploblem? Thanks very much.

 Note:kernel version v2.6.18,and the arch is x86_64.

 Regards
 laitianli

Bootdata ok (command line is ro root=LABEL=/ rhgb console=ttyS0,115200 
console=tty1 apic=debug acpi=on)
Linux version 2.6.18-std (laitianli@XCompiler) (gcc version 4.1.2 20080704 (Red 
Hat 4.1.2-55)) #13 SMP Thu Sep 10 16:35:59 CST 2015
BIOS-provided physical RAM map:
 BIOS-e820:  - 0009d400 (usable)
 BIOS-e820: 0009d400 - 000a (reserved)
 BIOS-e820: 000ca000 - 000cc000 (reserved)
 BIOS-e820: 000e - 0010 (reserved)
 BIOS-e820: 0010 - bf7a (usable)
 BIOS-e820: bf7a - bf7bd000 (ACPI data)
 BIOS-e820: bf7bd000 - bf7be000 (ACPI NVS)
 BIOS-e820: bf7be000 - bf7ff000 (reserved)
 BIOS-e820: bf80 - c000 (reserved)
 BIOS-e820: e000 - f000 (reserved)
 BIOS-e820: fec0 - fec1 (reserved)
 BIOS-e820: fee0 - fee01000 (reserved)
 BIOS-e820: ff00 - 0001 (reserved)
 BIOS-e820: 0001 - 00014000 (usable)
DMI present.
No NUMA configuration found
Faking a node at -00014000
Bootmem setup node 0 -00014000
ACPI: PM-Timer IO Port: 0x1008
ACPI: LAPIC (acpi_id[0x00] lapic_id[0x00] enabled)
Processor #0 7:14 APIC version 21
ACPI: LAPIC (acpi_id[0x01] lapic_id[0x02] enabled)
Processor #2 7:14 APIC version 21
ACPI: LAPIC (acpi_id[0x02] lapic_id[0x04] enabled)
Processor #4 7:14 APIC version 21
ACPI: LAPIC (acpi_id[0x03] lapic_id[0x06] enabled)
Processor #6 7:14 APIC version 21
ACPI: LAPIC_NMI (acpi_id[0x00] high edge lint[0x1])
ACPI: LAPIC_NMI (acpi_id[0x01] high edge lint[0x1])
ACPI: LAPIC_NMI (acpi_id[0x02] high edge lint[0x1])
ACPI: LAPIC_NMI (acpi_id[0x03] high edge lint[0x1])
ACPI: IOAPIC (id[0x01] address[0xfec0] gsi_base[0])
IOAPIC[0]: apic_id 1, version 32, address 0xfec0, GSI 0-23
ACPI: INT_SRC_OVR (bus 0 bus_irq 0 global_irq 2 high edge)
ACPI: INT_SRC_OVR (bus 0 bus_irq 9 global_irq 9 high level)
Setting APIC routing to physical flat
ACPI: HPET id: 0x8086a701 base: 0xfed0
Using ACPI (MADT) for SMP configuration information
Allocating PCI resources starting at c200 (gap: c000:2000)
SMP: Allowing 4 CPUs, 0 hotplug CPUs
Built 1 zonelists.  Total pages: 1028401
Kernel command line: ro root=LABEL=/ rhgb console=ttyS0,115200 console=tty1 
apic=debug acpi=on
Initializing CPU#0
PID hash table entries: 4096 (order: 12, 32768 bytes)
time.c: Using 14.318180 MHz WALL HPET GTOD HPET/TSC timer.
time.c: Detected 2394.071 MHz processor.
Console: colour VGA+ 80x25
Dentry cache hash table entries: 524288 (order: 10, 4194304 bytes)
Inode-cache hash table entries: 262144 (order: 9, 2097152 bytes)
Checking aperture...
PCI-DMA: Using software bounce buffering for IO (SWIOTLB)
Placing software IO TLB between 0x62c - 0xa2c
Memory: 4032088k/5242880k available (2276k kernel code, 153244k reserved, 1193k 
data, 200k init)
Calibrating delay using timer specific routine.. 4791.75 BogoMIPS (lpj=2395878)
Security Framework v1.0.0 initialized
Capability LSM initialized
Mount-cache hash table entries: 256
CPU: L1 I cache: 32K, L1 D cache: 32K
CPU: L2 cache: 256K
CPU: L3 cache: 8192K
using mwait in idle threads.
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 0
MCE: warning: using only 9 banks
CPU0: Thermal monitoring enabled (TM1)
SMP alternatives: switching to UP code
ACPI: Core revision 20060707
 tbxface-0107 [01] load_tables   : ACPI Tables successfully acquired
Parsing all Control Methods:
Table [DSDT](id 0007) - 513 Objects with 52 Devices 118 Methods 37 Regions
Parsing all Control Methods:
Table [SSDT](id 0004) - 68 Objects with 0 Devices 48 Methods 0 Regions
Parsing all Control Methods:
Table [SSDT](id 0005) - 8 Objects with 0 Devices 1 Methods 2 Regions
ACPI Namespace successfully loaded at root 815aa740
evxfevnt-0089 [02] enable: Transition to ACPI mode successful
enabled ExtINT on CPU#0
ENABLING IO-APIC IRQs
..TIMER: vector=0x31 apic1=0 pin1=2 apic2=-1 pin2=-1
Using local APIC timer interrupts.
result 8312740
Detected 8.312 MHz APIC timer.
SMP alternatives: switching to SMP code
Booting processor 1/4 APIC 0x2
Initializing CPU#1
masked ExtINT on CPU#1
Calibrating delay using timer specific routine.. 4787.98 BogoMIPS (lpj=2393991)
CPU: L1 I cache: 32K, L1 D cache: 32K
CPU: L2 cache: 256K
CPU: L3 cache: 8192K
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 1
MCE: warning: using only 9 banks
CPU1: Thermal monitoring enabled (TM1)
Intel(R) Xeon(R) CPU   X3430  @ 2.40GHz stepping 05
SMP alternatives: switching to SMP code

Re: Use a variable before it's declaration

2015-09-10 Thread Valdis . Kletnieks
On Thu, 10 Sep 2015 15:09:42 +0800, Rock Lee said:

> union thread_union init_thread_union __init_task_data =
>
>  { INIT_THREAD_INFO(init_task) };

'gcc -E' to see what this expands to.  All may not be as it seems. :)


pgpbElrwkwUP7.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Use a variable before it's declaration

2015-09-10 Thread Rock Lee
> Rock Lee  writes:
>
>> Hi, all:
>>  Here is a snippet of linux-v3.4 which drives me crazy.
>> Because init_task hasn't been declared yet when init_thread_union is
>> initializing. Why is there no compiling error? Any hint would be helpful.
>>
>> union thread_union init_thread_union __init_task_data =
>>
>>   { INIT_THREAD_INFO(init_task) };
>>
>>
>>
>> /*
>>
>>* Initial task structure.
>>
>>*
>>
>>* All other task structs will be allocated on slabs in fork.c
>>
>>*/
>>
>> struct task_struct init_task = INIT_TASK(init_task);
>
>
> Because init_task is declared "extern" in linux/sched.h
>
>
> Bjørn

I do something like that:

extern int b;
int a = b + 10;
int b = 20;

int main(void)
{
return 0;
}

No doubt, compiling error.

-- 
Rock Lee

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Set the ACPI=on on the cmdline, and the OS can not boot.

2015-09-10 Thread Valdis . Kletnieks
On Thu, 10 Sep 2015 17:41:51 +0800, tianlilai said:
>  When I set the ACPI=on on the cmdline,and the OS can not boot(If set
> ACPI=off, The system is OK). The attachmemt file is the booting log. Would
> help me slove this ploblem? Thanks very much.

>  Note:kernel version v2.6.18,and the arch is x86_64.

That's an ancient kernel - 9 years ago.  So you're missing the last 9 years
of ACPI fixes.

Also, problems like this are usually caused by the BIOS having buggy ACPI
tables that don't match the actual hardware - and if you're still on 2.6.18,
your BIOS is probably equally out of date.  And you would need to be a *lot*
more specific about the hardware than "x86_64" - for instance,"Dell Latitude
E6530 laptop with BIOS A16".

Unfortunately for you, I doubt anybody is going to want to give much more
assistance than this for free until you're running a kernel from the
last 2-3 years and the most recent BIOS the manufacturer has released.
(I can think of a number of people that will do this for contract work, but
be prepared to pay US$50/hour and up...)


pgpD7i5oZS2so.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


When to use threaded interrupts?

2015-09-10 Thread Kosta Zertsekel
Hi guys,

I hope I'm on right mailing list. :-)
I think I get the pro of using threaded interrupts - to decrease the maximum
interrupt latency on RT workloads and/or RT machines (servers, embedded,
etc.).

Also, I see that in 4.2 there are only ~76 drivers that use threaded
interrupt:
```
$ git grep -l IRQ_WAKE_THREAD | sort | grep -v "\.h" | wc -l
76
```

​So, I'd like to ask:
   - Why not **all** of the drivers use the threaded interrupts?
   - What are the cons of the threaded interrupts?​

Thanks,
--- KostaZ
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: When to use threaded interrupts?

2015-09-10 Thread Rami Rosen
Kosta,

Just a wild assumption: maybe the cost of incurring context switches ?
(comparing to tasklets)

Best Regards,
Rami Rosen
http://ramirose.wix.com/ramirosen



On 10 September 2015 at 20:49, Kosta Zertsekel  wrote:
> Hi guys,
>
> I hope I'm on right mailing list. :-)
> I think I get the pro of using threaded interrupts - to decrease the maximum
> interrupt latency on RT workloads and/or RT machines (servers, embedded,
> etc.).
>
> Also, I see that in 4.2 there are only ~76 drivers that use threaded
> interrupt:
> ```
> $ git grep -l IRQ_WAKE_THREAD | sort | grep -v "\.h" | wc -l
> 76
> ```
>
> So, I'd like to ask:
>- Why not **all** of the drivers use the threaded interrupts?
>- What are the cons of the threaded interrupts?
>
> Thanks,
> --- KostaZ
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Preceding a method call with (void)

2015-09-10 Thread Valdis . Kletnieks
On Thu, 10 Sep 2015 07:52:49 +0300, Kevin Wilson said:

> (void) myFunc(param1);
>
> I did not encounter such cases in the kernel code that I read, thus far.
>
> On the other hand, I did not saw in the kernel coding style doc
> anything which prohibits such usage.
>
> If I remember, using (void) before the method name is a way to tell
> explicitly that this method does not return any value,
> but I am not sure as for the exact reasons it is used (in userspace).

Well, if the function actually returns nothing, in kernel code we usually
declare it as:

void myFunc( int param1)
{
/* yadda yadda yadda *.
}

Given that, what reason is there for casting the return value with (void)?

(And if the function is actually   'int myFunc ( int param1) {...}',
why are you calling it and then ignoring the return value?  That's a clue
that you're abusing the API...)


pgpO8VnIka5RZ.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies