[PATCH] nvdimm: Fix devs leaks in scan_labels()

2024-06-03 Thread Li Zhijian
Don't allocate devs again when it's valid pointer which has pionted to
the memory allocated above with size (count + 2 * sizeof(dev)).

A kmemleak reports:
unreferenced object 0x88800dda1980 (size 16):
  comm "kworker/u10:5", pid 69, jiffies 4294671781
  hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  
  backtrace (crc 0):
[<c5dea560>] __kmalloc+0x32c/0x470
[<9ed43c83>] nd_region_register_namespaces+0x6fb/0x1120 [libnvdimm]
[<0e07a65c>] nd_region_probe+0xfe/0x210 [libnvdimm]
[<7b79ce5f>] nvdimm_bus_probe+0x7a/0x1e0 [libnvdimm]
[<a5f3da2e>] really_probe+0xc6/0x390
[<129e2a69>] __driver_probe_device+0x78/0x150
[<2dfed28b>] driver_probe_device+0x1e/0x90
[<e7048de2>] __device_attach_driver+0x85/0x110
[<32dca295>] bus_for_each_drv+0x85/0xe0
[<391c5a7d>] __device_attach+0xbe/0x1e0
[<26dabec0>] bus_probe_device+0x94/0xb0
[<c590d936>] device_add+0x656/0x870
[<3d69bfaa>] nd_async_device_register+0xe/0x50 [libnvdimm]
[<3f4c52a4>] async_run_entry_fn+0x2e/0x110
[<e201f4b0>] process_one_work+0x1ee/0x600
[<6d90d5a9>] worker_thread+0x183/0x350

Fixes: 1b40e09a1232 ("libnvdimm: blk labels and namespace instantiation")
Signed-off-by: Li Zhijian 
---
 drivers/nvdimm/namespace_devs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index d6d558f94d6b..56b016dbe307 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -1994,7 +1994,9 @@ static struct device **scan_labels(struct nd_region 
*nd_region)
/* Publish a zero-sized namespace for userspace to configure. */
nd_mapping_free_labels(nd_mapping);
 
-   devs = kcalloc(2, sizeof(dev), GFP_KERNEL);
+   /* devs probably has been allocated */
+   if (!devs)
+   devs = kcalloc(2, sizeof(dev), GFP_KERNEL);
if (!devs)
goto err;
 
-- 
2.29.2




[PATCH] vdpa: Convert sprintf/snprintf to sysfs_emit

2024-03-14 Thread Li Zhijian
Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

sprintf() will be converted as weel if they have.

Generally, this patch is generated by
make coccicheck M= MODE=patch \
COCCI=scripts/coccinelle/api/device_attr_show.cocci

No functional change intended

CC: "Michael S. Tsirkin" 
CC: Jason Wang 
CC: Xuan Zhuo 
CC: virtualizat...@lists.linux.dev
Signed-off-by: Li Zhijian 
---
This is a part of the work "Fix coccicheck device_attr_show warnings"[1]
Split them per subsystem so that the maintainer can review it easily
[1] https://lore.kernel.org/lkml/20240116041129.3937800-1-lizhij...@fujitsu.com/
---
 drivers/vdpa/vdpa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index d0695680b282..7b82b9aa91e9 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -98,7 +98,7 @@ static ssize_t driver_override_show(struct device *dev,
ssize_t len;
 
device_lock(dev);
-   len = snprintf(buf, PAGE_SIZE, "%s\n", vdev->driver_override);
+   len = sysfs_emit(buf, "%s\n", vdev->driver_override);
device_unlock(dev);
 
return len;
-- 
2.29.2




[PATCH] nvdimm: nvdimm_bus_register: Avoid adding device to the unregistered bus

2023-03-16 Thread Li Zhijian
nvdimm_bus_register() could be called from other modules, such as nfit,
but it can only be called after the nvdimm_bus_type is registered.

 BUG: kernel NULL pointer dereference, address: 0098
 #PF: supervisor read access in kernel mode
 #PF: error_code(0x) - not-present page
 PGD 0 P4D 0
 Oops:  [#1] PREEMPT SMP PTI
 CPU: 0 PID: 117 Comm: systemd-udevd Not tainted 6.2.0-rc6-pmem+ #97
 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
rel-1.16.0-0-gd239552ce722-prebuilt.qemu.org 04/01/2014
 RIP: 0010:bus_add_device+0x58/0x150
 Call Trace:
  
  device_add+0x3ac/0x980
  nvdimm_bus_register+0x16d/0x1d0
  acpi_nfit_init+0xb72/0x1f90 [nfit]
  acpi_nfit_add+0x1d5/0x200 [nfit]
  acpi_device_probe+0x45/0x160
  really_probe+0xce/0x390
  __driver_probe_device+0x78/0x180
  driver_probe_device+0x1e/0x90
  __driver_attach+0xd6/0x1d0
  bus_for_each_dev+0x7b/0xc0
  bus_add_driver+0x1ac/0x200
  driver_register+0x8f/0xf0
  nfit_init+0x164/0xff0 [nfit]
  do_one_initcall+0x5b/0x320
  do_init_module+0x4c/0x1f0
  __do_sys_finit_module+0xb4/0x130
  do_syscall_64+0x3b/0x90
  entry_SYSCALL_64_after_hwframe+0x72/0xdc

Signed-off-by: Li Zhijian 
---
 drivers/nvdimm/bus.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index ada61bbf49c1..ea66053072cb 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -28,6 +28,7 @@
 static int nvdimm_bus_major;
 struct class *nd_class;
 static DEFINE_IDA(nd_ida);
+static bool nvdimm_bus_type_registered;
 
 static int to_nd_device_type(struct device *dev)
 {
@@ -337,6 +338,10 @@ struct nvdimm_bus *nvdimm_bus_register(struct device 
*parent,
struct nvdimm_bus *nvdimm_bus;
int rc;
 
+   if (!nvdimm_bus_type_registered) {
+   pr_warn("nvdimm bus type is not registered\n");
+   return NULL;
+   }
nvdimm_bus = kzalloc(sizeof(*nvdimm_bus), GFP_KERNEL);
if (!nvdimm_bus)
return NULL;
@@ -1321,6 +1326,7 @@ int __init nvdimm_bus_init(void)
if (rc)
goto err_nd_bus;
 
+   nvdimm_bus_type_registered = true;
return 0;
 
  err_nd_bus:
@@ -1343,4 +1349,5 @@ void nvdimm_bus_exit(void)
unregister_chrdev(nvdimm_major, "dimmctl");
bus_unregister(_bus_type);
ida_destroy(_ida);
+   nvdimm_bus_type_registered = false;
 }
-- 
1.8.3.1




Re: [RFC PATCH 0/7] RDMA/rxe: On-Demand Paging on SoftRoCE

2022-09-08 Thread Li Zhijian

Daisuke

Great job.

I love this feature, before starting reviewing you patches, i tested it with 
QEMU(with fsdax memory-backend) migration
over RDMA where it worked for MLX5 before.

This time, with you ODP patches, it works on RXE though ibv_advise_mr may be 
not yet ready.


Thanks
Zhijian


On 07/09/2022 10:42, Daisuke Matsuda wrote:

Hi everyone,

This patch series implements the On-Demand Paging feature on SoftRoCE(rxe)
driver, which has been available only in mlx5 driver[1] so far.

[Overview]
When applications register a memory region(MR), RDMA drivers normally pin
pages in the MR so that physical addresses are never changed during RDMA
communication. This requires the MR to fit in physical memory and
inevitably leads to memory pressure. On the other hand, On-Demand Paging
(ODP) allows applications to register MRs without pinning pages. They are
paged-in when the driver requires and paged-out when the OS reclaims. As a
result, it is possible to register a large MR that does not fit in physical
memory without taking up so much physical memory.

[Why to add this feature?]
We, Fujitsu, have contributed to RDMA with a view to using it with
persistent memory. Persistent memory can host a filesystem that allows
applications to read/write files directly without involving page cache.
This is called FS-DAX(filesystem direct access) mode. There is a problem
that data on DAX-enabled filesystem cannot be duplicated with software RAID
or other hardware methods. Data replication with RDMA, which features
high-speed connections, is the best solution for the problem.

However, there is a known issue that hinders using RDMA with FS-DAX. When
RDMA operations to a file and update of the file metadata are processed
concurrently on the same node, illegal memory accesses can be executed,
disregarding the updated metadata. This is because RDMA operations do not
go through page cache but access data directly. There was an effort[2] to
solve this problem, but it was rejected in the end. Though there is no
general solution available, it is possible to work around the problem using
the ODP feature that has been available only in mlx5. ODP enables drivers
to update metadata before processing RDMA operations.

We have enhanced the rxe to expedite the usage of persistent memory. Our
contribution to rxe includes RDMA Atomic write[3] and RDMA Flush[4]. With
them being merged to rxe along with ODP, an environment will be ready for
developers to create and test software for RDMA with FS-DAX. There is a
library(librpma)[5] being developed for this purpose. This environment
can be used by anybody without any special hardware but an ordinary
computer with a normal NIC though it is inferior to hardware
implementations in terms of performance.

[Design considerations]
ODP has been available only in mlx5, but functions and data structures
that can be used commonly are provided in ib_uverbs(infiniband/core). The
interface is heavily dependent on HMM infrastructure[6], and this patchset
use them as much as possible. While mlx5 has both Explicit and Implicit ODP
features along with prefetch feature, this patchset implements the Explicit
ODP feature only.

As an important change, it is necessary to convert triple tasklets
(requester, responder and completer) to workqueues because they must be
able to sleep in order to trigger page fault before accessing MRs. I did a
test shown in the 2nd patch and found that the change makes the latency
higher while improving the bandwidth. Though it may be possible to create a
new independent workqueue for page fault execution, it is a not very
sensible solution since the tasklets have to busy-wait its completion in
that case.

If responder and completer sleep, it becomes more likely that packet drop
occurs because of overflow in receiver queue. There are multiple queues
involved, but, as SoftRoCE uses UDP, the most important one would be the
UDP buffers. The size can be configured in net.core.rmem_default and
net.core.rmem_max sysconfig parameters. Users should change these values in
case of packet drop, but page fault would be typically not so long as to
cause the problem.

[How does ODP work?]
"struct ib_umem_odp" is used to manage pages. It is created for each
ODP-enabled MR on its registration. This struct holds a pair of arrays
(dma_list/pfn_list) that serve as a driver page table. DMA addresses and
PFNs are stored in the driver page table. They are updated on page-in and
page-out, both of which use the common interface in ib_uverbs.

Page-in can occur when requester, responder or completer access an MR in
order to process RDMA operations. If they find that the pages being
accessed are not present on physical memory or requisite permissions are
not set on the pages, they provoke page fault to make pages present with
proper permissions and at the same time update the driver page table. After
confirming the presence of the pages, they execute memory access such as
read, write or atomic operations.


Re: [RFC PATCH rdma-next 01/10] RDMA: mr: Introduce is_pmem

2022-01-14 Thread Li, Zhijian

Copied to nvdimm list

Thanks

Zhijian


on 2022/1/6 14:12, Li Zhijian wrote:


Add Dan to the party :)

May i know whether there is any existing APIs to check whether
a va/page backs to a nvdimm/pmem ?



On 06/01/2022 08:21, Jason Gunthorpe wrote:

On Tue, Dec 28, 2021 at 04:07:08PM +0800, Li Zhijian wrote:

We can use it to indicate whether the registering mr is associated with
a pmem/nvdimm or not.

Currently, we only assign it in rxe driver, for other device/drivers,
they should implement it if needed.

RDMA FLUSH will support the persistence feature for a pmem/nvdimm.

Signed-off-by: Li Zhijian 
  drivers/infiniband/sw/rxe/rxe_mr.c | 47 
++

  include/rdma/ib_verbs.h    |  1 +
  2 files changed, 48 insertions(+)

diff --git a/drivers/infiniband/sw/rxe/rxe_mr.c 
b/drivers/infiniband/sw/rxe/rxe_mr.c

index 7c4cd19a9db2..bcd5e7afa475 100644
+++ b/drivers/infiniband/sw/rxe/rxe_mr.c
@@ -162,6 +162,50 @@ void rxe_mr_init_dma(struct rxe_pd *pd, int 
access, struct rxe_mr *mr)

  mr->type = IB_MR_TYPE_DMA;
  }
  +// XXX: the logic is similar with mm/memory-failure.c
+static bool page_in_dev_pagemap(struct page *page)
+{
+    unsigned long pfn;
+    struct page *p;
+    struct dev_pagemap *pgmap = NULL;
+
+    pfn = page_to_pfn(page);
+    if (!pfn) {
+    pr_err("no such pfn for page %p\n", page);
+    return false;
+    }
+
+    p = pfn_to_online_page(pfn);
+    if (!p) {
+    if (pfn_valid(pfn)) {
+    pgmap = get_dev_pagemap(pfn, NULL);
+    if (pgmap)
+    put_dev_pagemap(pgmap);
+    }
+    }
+
+    return !!pgmap;

You need to get Dan to check this out, but I'm pretty sure this should
be more like this:

if (is_zone_device_page(page) && page->pgmap->type == 
MEMORY_DEVICE_FS_DAX)


Great, i have added him.







+static bool iova_in_pmem(struct rxe_mr *mr, u64 iova, int length)
+{
+    struct page *page = NULL;
+    char *vaddr = iova_to_vaddr(mr, iova, length);
+
+    if (!vaddr) {
+    pr_err("not a valid iova %llu\n", iova);
+    return false;
+    }
+
+    page = virt_to_page(vaddr);

And obviously this isn't uniform for the entire umem, so I don't even
know what this is supposed to mean.


My intention is to check if a memory region belongs to a nvdimm/pmem.
The approach is like that:
iova(user space)-+ +-> page -> page_in_dev_pagemap()
 | |
 +-> va(kernel space) -+
Since current MR's va is associated with map_set where it record the 
relations

between iova and va and page. Do do you mean we should travel map_set to
get its page ? or by any other ways.








diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6e9ad656ecb7..822ebb3425dc 100644
+++ b/include/rdma/ib_verbs.h
@@ -1807,6 +1807,7 @@ struct ib_mr {
  unsigned int   page_size;
  enum ib_mr_type   type;
  bool   need_inval;
+    bool   is_pmem;

Or why it is being stored in the global struct?


Indeed, it's not strong necessary. but i think is_pmem should belongs 
to a ib_mr
so that it can be checked by other general code when they needed even 
though no

one does such checking so far.


Thanks
Zhijian





Jason








Re: RDMA/rpma + fsdax(ext4) was broken since 36f30e486d

2021-08-27 Thread Li, Zhijian



on 2021/8/27 21:16, Jason Gunthorpe wrote:

On Fri, Aug 27, 2021 at 09:05:21PM +0800, Li, Zhijian wrote:

Yes, can you send a proper patch and include the mm mailing list?


Of course, my pleasure

Thanks






Re: RDMA/rpma + fsdax(ext4) was broken since 36f30e486d

2021-08-27 Thread Li, Zhijian



on 2021/8/27 20:10, Jason Gunthorpe wrote:

On Fri, Aug 27, 2021 at 08:15:40AM +, lizhij...@fujitsu.com wrote:

i looked over the change-log of hmm_vma_handle_pte(), and found that before
4055062 ("mm/hmm: add missing call to hmm_pte_need_fault in HMM_PFN_SPECIAL 
handling")

hmm_vma_handle_pte() will not check pte_special(pte) if pte_devmap(pte) is true.

when we reached
"if (pte_special(pte) && !is_zero_pfn(pte_pfn(pte))) {"
the pte have already presented and its pte's flag already fulfilled the request 
flags.


My question is that
Per https://01.org/blogs/dave/2020/linux-consumption-x86-page-table-bits,
pte_devmap(pte) and pte_special(pte) could be both true in fsdax user case, 
right ?

How? what code creates that?

I see:

insert_pfn():
/* Ok, finally just insert the thing.. */
if (pfn_t_devmap(pfn))
entry = pte_mkdevmap(pfn_t_pte(pfn, prot));
else
entry = pte_mkspecial(pfn_t_pte(pfn, prot));

So what code path ends up setting both bits?


 pte_mkdevmap() will set both _PAGE_SPECIAL | PAGE_DEVMAP

 395 static inline pte_t pte_mkdevmap(pte_t pte)
 396 {
 397 return pte_set_flags(pte, _PAGE_SPECIAL|_PAGE_DEVMAP);
 398 }

below is a calltrace example

[  400.728559] Call Trace:
[  400.731595] dump_stack+0x6d/0x8b
[  400.735536] insert_pfn+0x16c/0x180
[  400.739596] __vm_insert_mixed+0x84/0xc0
[  400.744144] dax_iomap_pte_fault+0x845/0x870
[  400.749089] ext4_dax_huge_fault+0x171/0x1e0
[  400.754096] __do_fault+0x31/0xe0
[  400.758090]  ? pmd_devmap_trans_unstable+0x37/0x90
[  400.763541] handle_mm_fault+0x11b1/0x1680
[  400.768260] exc_page_fault+0x2f4/0x570
[  400.772788]  ? asm_exc_page_fault+0x8/0x30
[  400.777539]  asm_exc_page_fault+0x1e/0x30


So is my previous change reasonable ?

Thanks

Zhijian






Re: [kmemleak] b751c52bb5: BUG:kernel_hang_in_boot_stage

2020-06-10 Thread Li Zhijian




On 6/10/20 6:56 PM, Catalin Marinas wrote:

On Wed, Jun 10, 2020 at 03:51:56PM +0800, kernel test robot wrote:

FYI, we noticed the following commit (built with gcc-7):

commit: b751c52bb587ae66f773b15204ef7a147467f4c7 ("kmemleak: increase 
DEBUG_KMEMLEAK_EARLY_LOG_SIZE default to 16K")
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

in testcase: boot

on test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 8G

[...]

BUG: kernel hang in boot stage

To reproduce:

 # build kernel
cd linux
cp config-5.3.0-11789-gb751c52bb587a .config
make HOSTCC=gcc-7 CC=gcc-7 ARCH=i386 olddefconfig prepare 
modules_prepare bzImage

I've never tried kmemleak on i386.

Anyway, I'm not sure what caused the hang (or whether it's a hang at
all) but I suspect prior to the above commit, kmemleak probably just
disabled itself (early log  buffer exceeded).



So the bug may have been
there already,

I think so


only that kmemleak started working and tripped over it
when the log buffer increased.

Is there a chance that the kernel got much slower with kmemleak enabled
and the test scripts timed out?



Does this problem still exist with the latest mainline?

Yes, that's true.

Thanks
Zhijian (0Day CI team)


Thanks.





Re: [LKP] Re: 28307d938f ("percpu: make pcpu_alloc() aware of current gfp .."): BUG: kernel reboot-without-warning in boot stage

2020-06-02 Thread Li Zhijian




On 6/2/20 8:18 PM, Filipe Manana wrote:

On 02/06/20 05:37, Li Zhijian wrote:

Hi Filipe,

LKP checked blow dmesg as the indicator in this problem


[    0.144174] RAMDISK: [mem 0x7fa2e000-0x7fff]
[    0.144559] ACPI: Early table checksum verification disabled
[    0.144985] ACPI: RSDP 0x000F5850 14 (v00 BOCHS )
[    0.145424] ACPI: RSDT 0xBFFE15C9 30 (v01 BOCHS
BXPCRSDT 0001 BXPC 0001)
[    0.146051] ACPI: FACP 0xBFFE149D 74 (v01 BOCHS
BXPCFACP 0001 BXPC 0001)
BUG: kernel reboot-without-warning in boot stage


And i have reproduced it with script in attachment. this issue is gone
when i reverted this commit 28307d938f

Please note that
- i reproduced it with kernel compiled by gcc-5
- i failed to reproduce it in kernel compiled by gcc-7 so far

Odd.


Indeed !

i tested gcc-5 gcc-6 gcc-7, only gcc-5 triggered this issue, kernel 
built with gcc6 and gcc-7 works well


lizhijian@shao2-debian:~$ gcc-6 --version
gcc-6 (Debian 6.5.0-2) 6.5.0 20181026
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

lizhijian@shao2-debian:~$ gcc-5 --version
gcc-5 (Debian 5.5.0-12) 5.5.0 20171010
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

lizhijian@shao2-debian:~$ gcc-7 --version
gcc-7 (Debian 7.5.0-3) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Thanks
Zhijian


Here I tested with:

$ gcc --version
gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516
Copyright (C) 2016 Free Software Foundation, Inc.





Re: [LKP] Re: 28307d938f ("percpu: make pcpu_alloc() aware of current gfp .."): BUG: kernel reboot-without-warning in boot stage

2020-06-01 Thread Li Zhijian

Hi Filipe,

LKP checked blow dmesg as the indicator in this problem


[0.144174] RAMDISK: [mem 0x7fa2e000-0x7fff]
[0.144559] ACPI: Early table checksum verification disabled
[0.144985] ACPI: RSDP 0x000F5850 14 (v00 BOCHS )
[0.145424] ACPI: RSDT 0xBFFE15C9 30 (v01 BOCHS  BXPCRSDT 
0001 BXPC 0001)
[0.146051] ACPI: FACP 0xBFFE149D 74 (v01 BOCHS  BXPCFACP 
0001 BXPC 0001)
BUG: kernel reboot-without-warning in boot stage



And i have reproduced it with script in attachment. this issue is gone 
when i reverted this commit 28307d938f


Please note that
- i reproduced it with kernel compiled by gcc-5
- i failed to reproduce it in kernel compiled by gcc-7 so far

:~/1787$ ./reproduce.sh obj/arch/x86/boot/bzImage
qemu-system-x86_64 -enable-kvm -cpu Haswell,+smep,+smap -kernel 
obj/arch/x86/boot/bzImage -m 8192 -smp 2 -device e1000,netdev=net0 
-netdev user,id=net0,hostfwd=tcp::32032-:22 -boot order=nc -no-reboot 
-watchdog i6300esb -watchdog-action debug -rtc base=localtime -serial 
stdio -display none -monitor null -append root=/dev/ram0 
hung_task_panic=1 debug apic=debug sysrq_always_enabled 
rcupdate.rcu_cpu_stall_timeout=100 net.ifnames=0 printk.devkmsg=on 
panic=-1 softlockup_panic=1 nmi_watchdog=panic oops=panic load_ramdisk=2 
prompt_ramdisk=0 drbd.minor_count=8 systemd.log_level=err 
ignore_loglevel console=tty0 earlyprintk=ttyS0,115200 
console=ttyS0,115200 vga=normal rw rcuperf.shutdown=0 watchdog_thresh=60

early console in setup code
Wrong EFI loader signature.
early console in extract_kernel
input_data: 0x06f752d8
input_len: 0x0130dd3c
output: 0x0100
output_len: 0x07200a48
kernel_total_size: 0x06826000
needed_size: 0x0740
trampoline_32bit: 0x0009d000

Decompressing Linux... Parsing ELF... done.
Booting the kernel.
[    0.00] Linux version 5.7.0-rc4-00168-g28307d938fb2 
(lizhijian@shao2-debian) (gcc version 5.5.0 20171010 (Debian 5.5.0-12), 
GNU ld (GNU Binutils for Debian) 2.34) #2 SMP PREEMPT Tue Jun 2 11:23:59 
CST 2020
[    0.00] Command line: root=/dev/ram0 hung_task_panic=1 debug 
apic=debug sysrq_always_enabled rcupdate.rcu_cpu_stall_timeout=100 
net.ifnames=0 printk.devkmsg=on panic=-1 softlockup_panic=1 
nmi_watchdog=panic oops=panic load_ramdisk=2 prompt_ramdisk=0 
drbd.minor_count=8 systemd.log_level=err ignore_loglevel console=tty0 
earlyprintk=ttyS0,115200 console=ttyS0,115200 vga=normal rw 
rcuperf.shutdown=0 watchdog_thresh=60
[    0.00] x86/fpu: Supporting XSAVE feature 0x001: 'x87 floating 
point registers'

[    0.00] x86/fpu: Supporting XSAVE feature 0x002: 'SSE registers'
[    0.00] x86/fpu: Supporting XSAVE feature 0x004: 'AVX registers'
[    0.00] x86/fpu: xstate_offset[2]:  576, xstate_sizes[2]: 256
[    0.00] x86/fpu: Enabled xstate features 0x7, context size is 832 
bytes, using 'standard' format.

[    0.00] BIOS-provided physical RAM map:
[    0.00] BIOS-e820: [mem 0x-0x0009fbff] usable
[    0.00] BIOS-e820: [mem 0x0009fc00-0x0009] 
reserved
[    0.00] BIOS-e820: [mem 0x000f-0x000f] 
reserved

[    0.00] BIOS-e820: [mem 0x0010-0xbffd] usable
[    0.00] BIOS-e820: [mem 0xbffe-0xbfff] 
reserved
[    0.00] BIOS-e820: [mem 0xfeffc000-0xfeff] 
reserved
[    0.00] BIOS-e820: [mem 0xfffc-0x] 
reserved

[    0.00] BIOS-e820: [mem 0x0001-0x00023fff] usable
[    0.00] printk: debug: ignoring loglevel setting.
[    0.00] printk: bootconsole [earlyser0] enabled
[    0.00] NX (Execute Disable) protection: active
[    0.00] SMBIOS 2.8 present.
[    0.00] DMI: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.12.0-1 04/01/2014

[    0.00] Hypervisor detected: KVM
[    0.00] kvm-clock: Using msrs 4b564d01 and 4b564d00
[    0.02] kvm-clock: cpu 0, msr 7601001, primary cpu clock
[    0.02] kvm-clock: using sched offset of 2661499940 cycles
[    0.000603] clocksource: kvm-clock: mask: 0x 
max_cycles: 0x1cd42e4dffb, max_idle_ns: 881590591483 ns

[    0.002261] tsc: Detected 3407.998 MHz processor
[    0.005351] e820: update [mem 0x-0x0fff] usable ==> reserved
[    0.005986] e820: remove [mem 0x000a-0x000f] usable
[    0.006535] last_pfn = 0x24 max_arch_pfn = 0x4
[    0.007091] MTRR default type: write-back
[    0.007477] MTRR fixed ranges enabled:
[    0.007845]   0-9 write-back
[    0.008191]   A-B uncachable
[    0.008536]   C-F write-protect
[    0.008906] MTRR variable ranges enabled:
[    0.009293]   0 base 00C000 mask FFC000 uncachable
[    0.009818]   1 disabled
[    0.010064]   2 disabled
[    0.010314]   3 disabled
[    0.010561]   4 disabled
[    0.010822]   5 disabled
[    0.011072]   6 

Re: [PATCH] selftests:mptcp: fix empty optstring

2020-05-10 Thread Li Zhijian

ping


On 4/2/20 2:52 PM, Li Zhijian wrote:

From: Li Zhijian 

Signed-off-by: Li Zhijian 
---
  tools/testing/selftests/net/mptcp/pm_netlink.sh | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh 
b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 9172746b6cf0..8c7998c64d9e 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -8,8 +8,7 @@ usage() {
echo "Usage: $0 [ -h ]"
  }
  
-

-while getopts "$optstring" option;do
+while getopts "h" option;do
case "$option" in
"h")
usage $0






Re: [LKP] Re: [pipe] f2af7d90e2: xfstests.btrfs.052.fail

2020-05-10 Thread Li Zhijian

Hi Matthew

with a quick look into the dmesg
looks this commit broke the preparation of LKP tests

[   32.677588] install debs round two: dpkg -i --force-confdef 
--force-depends /opt/deb/gawk_1%3a4.1.4+dfsg-1_amd64.deb

[ 32.677593]-
[   32.697180] tar: ./control: Cannot write: Invalid argument
[ 32.697184]-
[   32.705025] tar: ./md5sums: Cannot write: Invalid argument
[ 32.705030]-
[   32.710034] tar: ./postinst: Cannot write: Invalid argument
[ 32.710039]-
[   32.743721] tar: ./prerm: Cannot write: Invalid argument

i tried apt command, it also failed with this commit
root@vm-snb-186 ~# apt update
Ign:1 http://linux-ftp.sh.intel.com/pub/mirrors/debian stretch InRelease
Get:2 http://linux-ftp.sh.intel.com/pub/mirrors/debian testing InRelease 
[116 kB]

Ign:2 http://linux-ftp.sh.intel.com/pub/mirrors/debian testing InRelease
Get:3 http://linux-ftp.sh.intel.com/pub/mirrors/debian unstable 
InRelease [146 kB]

Ign:3 http://linux-ftp.sh.intel.com/pub/mirrors/debian unstable InRelease
Get:4 http://linux-ftp.sh.intel.com/pub/mirrors/debian stretch Release 
[118 kB]

Err:4 http://linux-ftp.sh.intel.com/pub/mirrors/debian stretch Release
  Error writing to output file - write (22: Invalid argument)
Get:5 http://linux-ftp.sh.intel.com/pub/mirrors/debian testing Release 
[115 kB]

Err:5 http://linux-ftp.sh.intel.com/pub/mirrors/debian testing Release
  Error writing to output file - write (22: Invalid argument)
Get:6 http://linux-ftp.sh.intel.com/pub/mirrors/debian unstable Release 
[145 kB]
Get:7 http://linux-ftp.sh.intel.com/pub/mirrors/debian unstable 
Release.gpg [1601 B]

Err:7 http://linux-ftp.sh.intel.com/pub/mirrors/debian unstable Release.gpg
  Error writing to output file - write (22: Invalid argument)
Reading package lists... Done
E: The repository 'http://linux-ftp.sh.intel.com/pub/mirrors/debian 
stretch Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is 
therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user 
configuration details.
E: The repository 'http://linux-ftp.sh.intel.com/pub/mirrors/debian 
testing Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is 
therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user 
configuration details.
E: The repository 'http://linux-ftp.sh.intel.com/pub/mirrors/debian 
unstable Release' is not signed.
N: Updating from such a repository can't be done securely, and is 
therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user 
configuration details.


everything works well without f2af7d90e2 in our environment


Thanks


On 5/11/20 9:16 AM, Matthew Wilcox wrote:

On Mon, May 11, 2020 at 09:09:57AM +0800, kernel test robot wrote:

 --- tests/btrfs/095.out2020-04-09 10:45:28.0 +0800
 +++ /lkp/benchmarks/xfstests/results//btrfs/095.out.bad2020-05-06 
21:13:51.276485703 +0800
 @@ -1,35 +1,9 @@
  QA output created by 095
 -Blocks modified: [135 - 164]
 -Blocks modified: [768 - 792]
 +awk: line 19: function strtonum never defined
 +awk: line 19: function strtonum never defined
 +awk: line 19: function strtonum never defined
 +awk: line 19: function strtonum never defined

This looks like a problem with the test setup.
___
LKP mailing list -- l...@lists.01.org
To unsubscribe send an email to lkp-le...@lists.01.org




Re: [PATCH] initramfs: clean old path before creating a hardlink

2018-11-26 Thread Li Zhijian



On 11/27/2018 07:34 AM, Andrew Morton wrote:

On Fri, 16 Nov 2018 15:12:48 +0800 Li Zhijian  wrote:


Previously, sys_link() will fail due to the new path is already existed.
this case ofen appears when we use a concated initrd, below is an
sample:

1) prepare a basic rootfs, it contains a regular files rc.local
lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
  #!/bin/sh
  echo "Running /etc/rc.local..."
yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n -9 
>../rootfs.cgz

2) create a extra initrd which also includes a etc/rc.local
lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
   File: 'rc.local'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -
   File: 'rc.local.hardlink'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -

lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n 
-9 >../rc-local.cgz
lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
.
etc
etc/rc.local.hardlink <<< it will be extracted first at this initrd
etc/rc.local

3) concate 2 initrds and boot
lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 1024 
-kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 earlyprint=ttyS0 
ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio -nodefaults

In this case, sys_link(2) will fail and return -EEXIST, so we can only
get the rc.local at rootfs.cgz instead of rc-local.cgz

I can't claim to understand this, but I believe you ;)


thank you.

IMO, people who use concatenated initrd(cat rootfs.cgz rc-local.cgz 
>concatenated-initrd.cgz),
could expect that the later initrd(rc-local.cgz) can overwrite the previous 
initrd(rootfs.cgz).

However the previous kernel can not ensure this.



How serious is this problem?  Do you think a 4.20 merge is justified?


It's critical for our scenario where it always concatenates multiple initrds.
and our scenario often use the latest kernel, so 4.20+ is good to us.




Or a -stable backport?  If so, why?

The forward declaration is unpleasing.  Why not simply move the function?


Got it, i will update in V2


Thanks



--- a/init/initramfs.c~initramfs-clean-old-path-before-creating-a-hardlink-fix
+++ a/init/initramfs.c
@@ -291,7 +291,17 @@ static int __init do_reset(void)
return 1;
  }
  
-static void __init clean_path(char *path, umode_t fmode);

+static void __init clean_path(char *path, umode_t fmode)
+{
+   struct kstat st;
+
+   if (!vfs_lstat(path, ) && (st.mode ^ fmode) & S_IFMT) {
+   if (S_ISDIR(st.mode))
+   ksys_rmdir(path);
+   else
+   ksys_unlink(path);
+   }
+}
  
  static int __init maybe_link(void)

  {
@@ -305,18 +315,6 @@ static int __init maybe_link(void)
return 0;
  }
  
-static void __init clean_path(char *path, umode_t fmode)

-{
-   struct kstat st;
-
-   if (!vfs_lstat(path, ) && (st.mode ^ fmode) & S_IFMT) {
-   if (S_ISDIR(st.mode))
-   ksys_rmdir(path);
-   else
-   ksys_unlink(path);
-   }
-}
-
  static __initdata int wfd;
  
  static int __init do_name(void)

_



.






Re: [PATCH] initramfs: clean old path before creating a hardlink

2018-11-26 Thread Li Zhijian



On 11/27/2018 07:34 AM, Andrew Morton wrote:

On Fri, 16 Nov 2018 15:12:48 +0800 Li Zhijian  wrote:


Previously, sys_link() will fail due to the new path is already existed.
this case ofen appears when we use a concated initrd, below is an
sample:

1) prepare a basic rootfs, it contains a regular files rc.local
lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
  #!/bin/sh
  echo "Running /etc/rc.local..."
yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n -9 
>../rootfs.cgz

2) create a extra initrd which also includes a etc/rc.local
lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
   File: 'rc.local'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -
   File: 'rc.local.hardlink'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -

lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n 
-9 >../rc-local.cgz
lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
.
etc
etc/rc.local.hardlink <<< it will be extracted first at this initrd
etc/rc.local

3) concate 2 initrds and boot
lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 1024 
-kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 earlyprint=ttyS0 
ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio -nodefaults

In this case, sys_link(2) will fail and return -EEXIST, so we can only
get the rc.local at rootfs.cgz instead of rc-local.cgz

I can't claim to understand this, but I believe you ;)


thank you.

IMO, people who use concatenated initrd(cat rootfs.cgz rc-local.cgz 
>concatenated-initrd.cgz),
could expect that the later initrd(rc-local.cgz) can overwrite the previous 
initrd(rootfs.cgz).

However the previous kernel can not ensure this.



How serious is this problem?  Do you think a 4.20 merge is justified?


It's critical for our scenario where it always concatenates multiple initrds.
and our scenario often use the latest kernel, so 4.20+ is good to us.




Or a -stable backport?  If so, why?

The forward declaration is unpleasing.  Why not simply move the function?


Got it, i will update in V2


Thanks



--- a/init/initramfs.c~initramfs-clean-old-path-before-creating-a-hardlink-fix
+++ a/init/initramfs.c
@@ -291,7 +291,17 @@ static int __init do_reset(void)
return 1;
  }
  
-static void __init clean_path(char *path, umode_t fmode);

+static void __init clean_path(char *path, umode_t fmode)
+{
+   struct kstat st;
+
+   if (!vfs_lstat(path, ) && (st.mode ^ fmode) & S_IFMT) {
+   if (S_ISDIR(st.mode))
+   ksys_rmdir(path);
+   else
+   ksys_unlink(path);
+   }
+}
  
  static int __init maybe_link(void)

  {
@@ -305,18 +315,6 @@ static int __init maybe_link(void)
return 0;
  }
  
-static void __init clean_path(char *path, umode_t fmode)

-{
-   struct kstat st;
-
-   if (!vfs_lstat(path, ) && (st.mode ^ fmode) & S_IFMT) {
-   if (S_ISDIR(st.mode))
-   ksys_rmdir(path);
-   else
-   ksys_unlink(path);
-   }
-}
-
  static __initdata int wfd;
  
  static int __init do_name(void)

_



.






Re: [PATCH] initramfs: clean old path before creating a hardlink

2018-11-21 Thread Li Zhijian

ping

This patch is to fix initrd cannot be extracted properly in some cases.


Thanks


On 11/16/2018 03:12 PM, Li Zhijian wrote:

Previously, sys_link() will fail due to the new path is already existed.
this case ofen appears when we use a concated initrd, below is an
sample:

1) prepare a basic rootfs, it contains a regular files rc.local
lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
  #!/bin/sh
  echo "Running /etc/rc.local..."
yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n -9 
>../rootfs.cgz

2) create a extra initrd which also includes a etc/rc.local
lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
   File: 'rc.local'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -
   File: 'rc.local.hardlink'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -

lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n 
-9 >../rc-local.cgz
lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
.
etc
etc/rc.local.hardlink <<< it will be extracted first at this initrd
etc/rc.local

3) concate 2 initrds and boot
lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 1024 
-kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 earlyprint=ttyS0 
ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio -nodefaults

In this case, sys_link(2) will fail and return -EEXIST, so we can only
get the rc.local at rootfs.cgz instead of rc-local.cgz

CC: Philip Li 
Signed-off-by: Li Zhijian 
---
  init/initramfs.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 6405577..381fd4c 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -291,12 +291,16 @@ static int __init do_reset(void)
return 1;
  }
  
+static void __init clean_path(char *path, umode_t fmode);

+
  static int __init maybe_link(void)
  {
if (nlink >= 2) {
char *old = find_link(major, minor, ino, mode, collected);
-   if (old)
+   if (old) {
+   clean_path(collected, 0);
return (ksys_link(old, collected) < 0) ? -1 : 1;
+   }
}
return 0;
  }





Re: [PATCH] initramfs: clean old path before creating a hardlink

2018-11-21 Thread Li Zhijian

ping

This patch is to fix initrd cannot be extracted properly in some cases.


Thanks


On 11/16/2018 03:12 PM, Li Zhijian wrote:

Previously, sys_link() will fail due to the new path is already existed.
this case ofen appears when we use a concated initrd, below is an
sample:

1) prepare a basic rootfs, it contains a regular files rc.local
lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
  #!/bin/sh
  echo "Running /etc/rc.local..."
yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n -9 
>../rootfs.cgz

2) create a extra initrd which also includes a etc/rc.local
lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
   File: 'rc.local'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -
   File: 'rc.local.hardlink'
   Size: 14 Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
  Birth: -

lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n 
-9 >../rc-local.cgz
lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
.
etc
etc/rc.local.hardlink <<< it will be extracted first at this initrd
etc/rc.local

3) concate 2 initrds and boot
lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 1024 
-kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 earlyprint=ttyS0 
ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio -nodefaults

In this case, sys_link(2) will fail and return -EEXIST, so we can only
get the rc.local at rootfs.cgz instead of rc-local.cgz

CC: Philip Li 
Signed-off-by: Li Zhijian 
---
  init/initramfs.c | 6 +-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 6405577..381fd4c 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -291,12 +291,16 @@ static int __init do_reset(void)
return 1;
  }
  
+static void __init clean_path(char *path, umode_t fmode);

+
  static int __init maybe_link(void)
  {
if (nlink >= 2) {
char *old = find_link(major, minor, ino, mode, collected);
-   if (old)
+   if (old) {
+   clean_path(collected, 0);
return (ksys_link(old, collected) < 0) ? -1 : 1;
+   }
}
return 0;
  }





[PATCH] initramfs: clean old path before creating a hardlink

2018-11-15 Thread Li Zhijian
Previously, sys_link() will fail due to the new path is already existed.
this case ofen appears when we use a concated initrd, below is an
sample:

1) prepare a basic rootfs, it contains a regular files rc.local
lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
 #!/bin/sh
 echo "Running /etc/rc.local..."
yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n 
-9 >../rootfs.cgz

2) create a extra initrd which also includes a etc/rc.local
lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
  File: 'rc.local'
  Size: 14  Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
 Birth: -
  File: 'rc.local.hardlink'
  Size: 14  Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
 Birth: -

lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip 
-n -9 >../rc-local.cgz
lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
.
etc
etc/rc.local.hardlink <<< it will be extracted first at this initrd
etc/rc.local

3) concate 2 initrds and boot
lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 
1024 -kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 
earlyprint=ttyS0 ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio 
-nodefaults

In this case, sys_link(2) will fail and return -EEXIST, so we can only
get the rc.local at rootfs.cgz instead of rc-local.cgz

CC: Philip Li 
Signed-off-by: Li Zhijian 
---
 init/initramfs.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 6405577..381fd4c 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -291,12 +291,16 @@ static int __init do_reset(void)
return 1;
 }
 
+static void __init clean_path(char *path, umode_t fmode);
+
 static int __init maybe_link(void)
 {
if (nlink >= 2) {
char *old = find_link(major, minor, ino, mode, collected);
-   if (old)
+   if (old) {
+   clean_path(collected, 0);
return (ksys_link(old, collected) < 0) ? -1 : 1;
+   }
}
return 0;
 }
-- 
2.7.4



[PATCH] initramfs: clean old path before creating a hardlink

2018-11-15 Thread Li Zhijian
Previously, sys_link() will fail due to the new path is already existed.
this case ofen appears when we use a concated initrd, below is an
sample:

1) prepare a basic rootfs, it contains a regular files rc.local
lizhijian@:~/yocto-tiny-i386-2016-04-22$ cat etc/rc.local
 #!/bin/sh
 echo "Running /etc/rc.local..."
yocto-tiny-i386-2016-04-22$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip -n 
-9 >../rootfs.cgz

2) create a extra initrd which also includes a etc/rc.local
lizhijian@:~/lkp-x86_64/etc$ echo "append initrd" >rc.local
lizhijian@:~/lkp/lkp-x86_64/etc$ cat rc.local
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ ln rc.local rc.local.hardlink
append initrd
lizhijian@:~/lkp/lkp-x86_64/etc$ stat rc.local rc.local.hardlink
  File: 'rc.local'
  Size: 14  Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
 Birth: -
  File: 'rc.local.hardlink'
  Size: 14  Blocks: 8  IO Block: 4096   regular file
Device: 801h/2049d  Inode: 11296086Links: 2
Access: (0664/-rw-rw-r--)  Uid: ( 1002/lizhijian)   Gid: ( 1002/lizhijian)
Access: 2018-11-15 16:08:28.654464815 +0800
Modify: 2018-11-15 16:07:57.514903210 +0800
Change: 2018-11-15 16:08:24.180228872 +0800
 Birth: -

lizhijian@:~/lkp/lkp-x86_64$ find . | sed 's,^\./,,' | cpio -o -H newc | gzip 
-n -9 >../rc-local.cgz
lizhijian@:~/lkp/lkp-x86_64$ gzip -dc ../rc-local.cgz | cpio -t
.
etc
etc/rc.local.hardlink <<< it will be extracted first at this initrd
etc/rc.local

3) concate 2 initrds and boot
lizhijian@:~/lkp$ cat rootfs.cgz rc-local.cgz >concate-initrd.cgz
lizhijian@:~/lkp$ qemu-system-x86_64 -nographic -enable-kvm -cpu host -smp 1 -m 
1024 -kernel ~/lkp/linux/arch/x86/boot/bzImage -append "console=ttyS0 
earlyprint=ttyS0 ignore_loglevel" -initrd ./concate-initr.cgz -serial stdio 
-nodefaults

In this case, sys_link(2) will fail and return -EEXIST, so we can only
get the rc.local at rootfs.cgz instead of rc-local.cgz

CC: Philip Li 
Signed-off-by: Li Zhijian 
---
 init/initramfs.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/init/initramfs.c b/init/initramfs.c
index 6405577..381fd4c 100644
--- a/init/initramfs.c
+++ b/init/initramfs.c
@@ -291,12 +291,16 @@ static int __init do_reset(void)
return 1;
 }
 
+static void __init clean_path(char *path, umode_t fmode);
+
 static int __init maybe_link(void)
 {
if (nlink >= 2) {
char *old = find_link(major, minor, ino, mode, collected);
-   if (old)
+   if (old) {
+   clean_path(collected, 0);
return (ksys_link(old, collected) < 0) ? -1 : 1;
+   }
}
return 0;
 }
-- 
2.7.4



Re: [LKP] [tools/bpf] f6f3bac08f: stderr.failed_to_prepare_for_bpf

2018-11-06 Thread Li Zhijian



On 11/6/2018 9:47 AM, Yonghong Song wrote:

I cannot reproduce in my local fc28 system with the attached steps.

The netlink_dumper.c file, could you confirm whether the following
header files are missing form you rhel-7.2 host?

#include 
#include 

I suspect you probably miss linux/tc_act/tc_bpf.h. But could you confirm
it? If this is the case, I can fix the problem by adding tc_bpf.h into
tools/include/uapi directory.


we have installed , but it's a bit old

root@lkp-bdw-ep3 ~/linux-f6f3bac08f# diff /usr/include/linux/tc_act/tc_bpf.h 
./include/uapi/linux/tc_act/tc_bpf.h -u
--- /usr/include/linux/tc_act/tc_bpf.h  2018-03-02 07:52:22.0 +
+++ ./include/uapi/linux/tc_act/tc_bpf.h2018-09-07 05:34:08.0 
+
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
 /*
  * Copyright (c) 2015 Jiri Pirko 
  *
@@ -27,6 +28,8 @@
TCA_ACT_BPF_FD,
TCA_ACT_BPF_NAME,
TCA_ACT_BPF_PAD,
+   TCA_ACT_BPF_TAG,
+   TCA_ACT_BPF_ID,
__TCA_ACT_BPF_MAX,
 };
 #define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)

and beside linux/tc_act/tc_bpf.h, it also requires a newer linux/pkt_cls.h to 
avoid:
root@lkp-bdw-ep3 ~/linux-f6f3bac08f/tools/bpf/bpftool# make V=1
[...snip...]
gcc -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers 
-DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ -I/root/linux-f6f3bac08f/kernel/bpf/ 
-I/root/linux-f6f3bac08f/tools/include -I/root/linux-f6f3bac08f/tools/include/uapi 
-I/root/linux-f6f3bac08f/tools/lib/bpf -I/root/linux-f6f3bac08f/tools/perf 
-DBPFTOOL_VERSION='"4.19.0-rc2"' -DCOMPAT_NEED_REALLOCARRAY   -c -MMD -o netlink_dumper.o 
netlink_dumper.c
make -C /root/linux-f6f3bac08f/tools/lib/bpf/ OUTPUT= libbpf.a
make[1]: Entering directory '/root/linux-f6f3bac08f/tools/lib/bpf'
netlink_dumper.c: In function 'do_bpf_filter_dump':
netlink_dumper.c:153:9: error: 'TCA_BPF_ID' undeclared (first use in this 
function)
  if (tb[TCA_BPF_ID])
 ^~
netlink_dumper.c:153:9: note: each undeclared identifier is reported only once 
for each function it appears in
netlink_dumper.c:155:9: error: 'TCA_BPF_TAG' undeclared (first use in this 
function)
  if (tb[TCA_BPF_TAG])
 ^~~
Makefile:96: recipe for target 'netlink_dumper.o' failed
make: *** [netlink_dumper.o] Error 1
make: *** Waiting for unfinished jobs
make -f /root/linux-f6f3bac08f/tools/build/Makefile.build dir=. obj=libbpf
make[1]: Leaving directory '/root/linux-f6f3bac08f/tools/lib/bpf'


In this case, i'm not clear either i should upgrade system's linux header by 
myself or fix the tools on you side.


Thanks
Zhijian

 



Thanks,

Yonghong


On 11/4/18 9:36 PM, kernel test robot wrote:

FYI, we noticed the following commit (built with gcc-7):

commit: f6f3bac08ff9855d803081a353a1fafaa8845739 ("tools/bpf: bpftool: add net 
support")
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

in testcase: bpf_offload
with following parameters:

ucode: 0xb2e



on test machine: 88 threads Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz with 64G 
memory

caused below changes (please refer to attached dmesg/kmsg for entire 
log/backtrace):




KERNEL SELFTESTS: linux_headers_dir is 
/usr/src/linux-headers-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739
2018-11-03 10:11:02 cd 
/usr/src/linux-selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/testing/selftests
2018-11-03 10:11:02 ln -sf /usr/bin/clang-7 /usr/bin/clang
2018-11-03 10:11:02 ln -sf /usr/bin/llc-7 /usr/bin/llc
make: Entering directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf'

Auto-detecting system features:
...libbfd: [ OFF ]
...disassembler-four-args: [ OFF ]

CC   bpf_jit_disasm.o
LINK bpf_jit_disasm
CC   bpf_dbg.o
LINK bpf_dbg
CC   bpf_asm.o
BISONbpf_exp.yacc.c
CC   bpf_exp.yacc.o
FLEX bpf_exp.lex.c
CC   bpf_exp.lex.o
LINK bpf_asm
DESCEND  bpftool
make[1]: Entering directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf/bpftool'

Auto-detecting system features:
...libbfd: [ OFF ]
...disassembler-four-args: [ OFF ]

CC   map_perf_ring.o
CC   xlated_dumper.o
CC   perf.o
CC   prog.o
CC   btf_dumper.o
CC   net.o
CC   netlink_dumper.o
Makefile:96: recipe for target 'netlink_dumper.o' failed
make[1]: Leaving directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf/bpftool'
Makefile:99: recipe for target 'bpftool' failed
make: Leaving directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf'



To reproduce:

  git clone https://github.com/intel/lkp-tests.git
  cd lkp-tests

Re: [LKP] [tools/bpf] f6f3bac08f: stderr.failed_to_prepare_for_bpf

2018-11-06 Thread Li Zhijian



On 11/6/2018 9:47 AM, Yonghong Song wrote:

I cannot reproduce in my local fc28 system with the attached steps.

The netlink_dumper.c file, could you confirm whether the following
header files are missing form you rhel-7.2 host?

#include 
#include 

I suspect you probably miss linux/tc_act/tc_bpf.h. But could you confirm
it? If this is the case, I can fix the problem by adding tc_bpf.h into
tools/include/uapi directory.


we have installed , but it's a bit old

root@lkp-bdw-ep3 ~/linux-f6f3bac08f# diff /usr/include/linux/tc_act/tc_bpf.h 
./include/uapi/linux/tc_act/tc_bpf.h -u
--- /usr/include/linux/tc_act/tc_bpf.h  2018-03-02 07:52:22.0 +
+++ ./include/uapi/linux/tc_act/tc_bpf.h2018-09-07 05:34:08.0 
+
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
 /*
  * Copyright (c) 2015 Jiri Pirko 
  *
@@ -27,6 +28,8 @@
TCA_ACT_BPF_FD,
TCA_ACT_BPF_NAME,
TCA_ACT_BPF_PAD,
+   TCA_ACT_BPF_TAG,
+   TCA_ACT_BPF_ID,
__TCA_ACT_BPF_MAX,
 };
 #define TCA_ACT_BPF_MAX (__TCA_ACT_BPF_MAX - 1)

and beside linux/tc_act/tc_bpf.h, it also requires a newer linux/pkt_cls.h to 
avoid:
root@lkp-bdw-ep3 ~/linux-f6f3bac08f/tools/bpf/bpftool# make V=1
[...snip...]
gcc -O2 -W -Wall -Wextra -Wno-unused-parameter -Wshadow -Wno-missing-field-initializers 
-DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ -I/root/linux-f6f3bac08f/kernel/bpf/ 
-I/root/linux-f6f3bac08f/tools/include -I/root/linux-f6f3bac08f/tools/include/uapi 
-I/root/linux-f6f3bac08f/tools/lib/bpf -I/root/linux-f6f3bac08f/tools/perf 
-DBPFTOOL_VERSION='"4.19.0-rc2"' -DCOMPAT_NEED_REALLOCARRAY   -c -MMD -o netlink_dumper.o 
netlink_dumper.c
make -C /root/linux-f6f3bac08f/tools/lib/bpf/ OUTPUT= libbpf.a
make[1]: Entering directory '/root/linux-f6f3bac08f/tools/lib/bpf'
netlink_dumper.c: In function 'do_bpf_filter_dump':
netlink_dumper.c:153:9: error: 'TCA_BPF_ID' undeclared (first use in this 
function)
  if (tb[TCA_BPF_ID])
 ^~
netlink_dumper.c:153:9: note: each undeclared identifier is reported only once 
for each function it appears in
netlink_dumper.c:155:9: error: 'TCA_BPF_TAG' undeclared (first use in this 
function)
  if (tb[TCA_BPF_TAG])
 ^~~
Makefile:96: recipe for target 'netlink_dumper.o' failed
make: *** [netlink_dumper.o] Error 1
make: *** Waiting for unfinished jobs
make -f /root/linux-f6f3bac08f/tools/build/Makefile.build dir=. obj=libbpf
make[1]: Leaving directory '/root/linux-f6f3bac08f/tools/lib/bpf'


In this case, i'm not clear either i should upgrade system's linux header by 
myself or fix the tools on you side.


Thanks
Zhijian

 



Thanks,

Yonghong


On 11/4/18 9:36 PM, kernel test robot wrote:

FYI, we noticed the following commit (built with gcc-7):

commit: f6f3bac08ff9855d803081a353a1fafaa8845739 ("tools/bpf: bpftool: add net 
support")
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git master

in testcase: bpf_offload
with following parameters:

ucode: 0xb2e



on test machine: 88 threads Intel(R) Xeon(R) CPU E5-2699 v4 @ 2.20GHz with 64G 
memory

caused below changes (please refer to attached dmesg/kmsg for entire 
log/backtrace):




KERNEL SELFTESTS: linux_headers_dir is 
/usr/src/linux-headers-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739
2018-11-03 10:11:02 cd 
/usr/src/linux-selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/testing/selftests
2018-11-03 10:11:02 ln -sf /usr/bin/clang-7 /usr/bin/clang
2018-11-03 10:11:02 ln -sf /usr/bin/llc-7 /usr/bin/llc
make: Entering directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf'

Auto-detecting system features:
...libbfd: [ OFF ]
...disassembler-four-args: [ OFF ]

CC   bpf_jit_disasm.o
LINK bpf_jit_disasm
CC   bpf_dbg.o
LINK bpf_dbg
CC   bpf_asm.o
BISONbpf_exp.yacc.c
CC   bpf_exp.yacc.o
FLEX bpf_exp.lex.c
CC   bpf_exp.lex.o
LINK bpf_asm
DESCEND  bpftool
make[1]: Entering directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf/bpftool'

Auto-detecting system features:
...libbfd: [ OFF ]
...disassembler-four-args: [ OFF ]

CC   map_perf_ring.o
CC   xlated_dumper.o
CC   perf.o
CC   prog.o
CC   btf_dumper.o
CC   net.o
CC   netlink_dumper.o
Makefile:96: recipe for target 'netlink_dumper.o' failed
make[1]: Leaving directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf/bpftool'
Makefile:99: recipe for target 'bpftool' failed
make: Leaving directory 
'/usr/src/perf_selftests-x86_64-rhel-7.2-f6f3bac08ff9855d803081a353a1fafaa8845739/tools/bpf'



To reproduce:

  git clone https://github.com/intel/lkp-tests.git
  cd lkp-tests

Re: [PATCH] selftests/gpio: fix compiling errors

2018-10-10 Thread Li Zhijian



On 10/11/2018 04:25 AM, Shuah Khan wrote:

On 10/07/2018 08:32 AM, Li Zhijian wrote:

ping


On 09/21/2018 06:00 PM, Li Zhijian wrote:

lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests$ make
[...snip...]
make ARCH=x86 CROSS_COMPILE= -C ../../../gpio
make[2]: Entering directory '/home/lizj/linux/tools/gpio'
[...snip...]
make[3]: Leaving directory '/home/lizj/linux/tools/gpio'
    LINK /home/lizj/linux/tools/testing/selftests/gpiogpio-event-mon
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o  -lmount -I/usr/include/libmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2

in this patch
- correct target name to $OUTPUTgpio-utils.o
- pass OUTPUT to tools/gpio/Makefile
- support cleanup ../gpiogpio-hammer.o

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
   tools/testing/selftests/gpio/Makefile | 8 
   1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 4665cdb..7f9354a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -7,7 +7,7 @@ EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer 
../gpiolsgpio
   EXTRA_DIRS := ../gpioinclude/
   EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o
   EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o
-EXTRA_OBJS += ../gpiolsgpio.o
+EXTRA_OBJS += ../gpiolsgpio.o ../gpiogpio-hammer.o
     include ../lib.mk
   @@ -22,7 +22,7 @@ CFLAGS += -O2 -g -std=gnu99 -Wall 
-I../../../../usr/include/
   LDLIBS += -lmount -I/usr/include/libmount
     $(BINARIES):| khdr
-$(BINARIES): ../../../gpio/gpio-utils.o
+$(BINARIES): ../gpiogpio-utils.o
   -../../../gpio/gpio-utils.o:
-    make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+../gpiogpio-utils.o:
+    make OUTPUT=$(OUTPUT) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio

Is this still an issue in linux-kselftest next. I applied a few patches
from Fathi Boudra

Please check and let me know if this is till an issue.


This issue is gone in linux-kselftest next, please drop my patch. :)

Thans
 



thanks,
-- Shuah


.







Re: [PATCH] selftests/gpio: fix compiling errors

2018-10-10 Thread Li Zhijian



On 10/11/2018 04:25 AM, Shuah Khan wrote:

On 10/07/2018 08:32 AM, Li Zhijian wrote:

ping


On 09/21/2018 06:00 PM, Li Zhijian wrote:

lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests$ make
[...snip...]
make ARCH=x86 CROSS_COMPILE= -C ../../../gpio
make[2]: Entering directory '/home/lizj/linux/tools/gpio'
[...snip...]
make[3]: Leaving directory '/home/lizj/linux/tools/gpio'
    LINK /home/lizj/linux/tools/testing/selftests/gpiogpio-event-mon
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o  -lmount -I/usr/include/libmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2

in this patch
- correct target name to $OUTPUTgpio-utils.o
- pass OUTPUT to tools/gpio/Makefile
- support cleanup ../gpiogpio-hammer.o

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
   tools/testing/selftests/gpio/Makefile | 8 
   1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 4665cdb..7f9354a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -7,7 +7,7 @@ EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer 
../gpiolsgpio
   EXTRA_DIRS := ../gpioinclude/
   EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o
   EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o
-EXTRA_OBJS += ../gpiolsgpio.o
+EXTRA_OBJS += ../gpiolsgpio.o ../gpiogpio-hammer.o
     include ../lib.mk
   @@ -22,7 +22,7 @@ CFLAGS += -O2 -g -std=gnu99 -Wall 
-I../../../../usr/include/
   LDLIBS += -lmount -I/usr/include/libmount
     $(BINARIES):| khdr
-$(BINARIES): ../../../gpio/gpio-utils.o
+$(BINARIES): ../gpiogpio-utils.o
   -../../../gpio/gpio-utils.o:
-    make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+../gpiogpio-utils.o:
+    make OUTPUT=$(OUTPUT) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio

Is this still an issue in linux-kselftest next. I applied a few patches
from Fathi Boudra

Please check and let me know if this is till an issue.


This issue is gone in linux-kselftest next, please drop my patch. :)

Thans
 



thanks,
-- Shuah


.







Re: [PATCH] selftests/gpio: fix compiling errors

2018-10-07 Thread Li Zhijian

ping


On 09/21/2018 06:00 PM, Li Zhijian wrote:

lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests$ make
[...snip...]
make ARCH=x86 CROSS_COMPILE= -C ../../../gpio
make[2]: Entering directory '/home/lizj/linux/tools/gpio'
[...snip...]
make[3]: Leaving directory '/home/lizj/linux/tools/gpio'
   LINK /home/lizj/linux/tools/testing/selftests/gpiogpio-event-mon
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o  -lmount -I/usr/include/libmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2

in this patch
- correct target name to $OUTPUTgpio-utils.o
- pass OUTPUT to tools/gpio/Makefile
- support cleanup ../gpiogpio-hammer.o

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
  tools/testing/selftests/gpio/Makefile | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 4665cdb..7f9354a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -7,7 +7,7 @@ EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer 
../gpiolsgpio
  EXTRA_DIRS := ../gpioinclude/
  EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o
  EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o
-EXTRA_OBJS += ../gpiolsgpio.o
+EXTRA_OBJS += ../gpiolsgpio.o ../gpiogpio-hammer.o
  
  include ../lib.mk
  
@@ -22,7 +22,7 @@ CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/

  LDLIBS += -lmount -I/usr/include/libmount
  
  $(BINARIES):| khdr

-$(BINARIES): ../../../gpio/gpio-utils.o
+$(BINARIES): ../gpiogpio-utils.o
  
-../../../gpio/gpio-utils.o:

-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+../gpiogpio-utils.o:
+   make OUTPUT=$(OUTPUT) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio


--
Best regards.
Li Zhijian (8528)





Re: [PATCH] selftests/gpio: fix compiling errors

2018-10-07 Thread Li Zhijian

ping


On 09/21/2018 06:00 PM, Li Zhijian wrote:

lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests$ make
[...snip...]
make ARCH=x86 CROSS_COMPILE= -C ../../../gpio
make[2]: Entering directory '/home/lizj/linux/tools/gpio'
[...snip...]
make[3]: Leaving directory '/home/lizj/linux/tools/gpio'
   LINK /home/lizj/linux/tools/testing/selftests/gpiogpio-event-mon
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o  -lmount -I/usr/include/libmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2

in this patch
- correct target name to $OUTPUTgpio-utils.o
- pass OUTPUT to tools/gpio/Makefile
- support cleanup ../gpiogpio-hammer.o

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
  tools/testing/selftests/gpio/Makefile | 8 
  1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 4665cdb..7f9354a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -7,7 +7,7 @@ EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer 
../gpiolsgpio
  EXTRA_DIRS := ../gpioinclude/
  EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o
  EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o
-EXTRA_OBJS += ../gpiolsgpio.o
+EXTRA_OBJS += ../gpiolsgpio.o ../gpiogpio-hammer.o
  
  include ../lib.mk
  
@@ -22,7 +22,7 @@ CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/

  LDLIBS += -lmount -I/usr/include/libmount
  
  $(BINARIES):| khdr

-$(BINARIES): ../../../gpio/gpio-utils.o
+$(BINARIES): ../gpiogpio-utils.o
  
-../../../gpio/gpio-utils.o:

-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+../gpiogpio-utils.o:
+   make OUTPUT=$(OUTPUT) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio


--
Best regards.
Li Zhijian (8528)





[PATCH] selftests/gpio: fix compiling errors

2018-09-21 Thread Li Zhijian
lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests$ make
[...snip...]
make ARCH=x86 CROSS_COMPILE= -C ../../../gpio
make[2]: Entering directory '/home/lizj/linux/tools/gpio'
[...snip...]
make[3]: Leaving directory '/home/lizj/linux/tools/gpio'
  LINK /home/lizj/linux/tools/testing/selftests/gpiogpio-event-mon
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o  -lmount -I/usr/include/libmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2

in this patch
- correct target name to $OUTPUTgpio-utils.o
- pass OUTPUT to tools/gpio/Makefile
- support cleanup ../gpiogpio-hammer.o

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/gpio/Makefile | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 4665cdb..7f9354a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -7,7 +7,7 @@ EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer 
../gpiolsgpio
 EXTRA_DIRS := ../gpioinclude/
 EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o
 EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o
-EXTRA_OBJS += ../gpiolsgpio.o
+EXTRA_OBJS += ../gpiolsgpio.o ../gpiogpio-hammer.o
 
 include ../lib.mk
 
@@ -22,7 +22,7 @@ CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
 LDLIBS += -lmount -I/usr/include/libmount
 
 $(BINARIES):| khdr
-$(BINARIES): ../../../gpio/gpio-utils.o
+$(BINARIES): ../gpiogpio-utils.o
 
-../../../gpio/gpio-utils.o:
-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+../gpiogpio-utils.o:
+   make OUTPUT=$(OUTPUT) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio
-- 
2.7.4



[PATCH] selftests/gpio: fix compiling errors

2018-09-21 Thread Li Zhijian
lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests$ make
[...snip...]
make ARCH=x86 CROSS_COMPILE= -C ../../../gpio
make[2]: Entering directory '/home/lizj/linux/tools/gpio'
[...snip...]
make[3]: Leaving directory '/home/lizj/linux/tools/gpio'
  LINK /home/lizj/linux/tools/testing/selftests/gpiogpio-event-mon
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o  -lmount -I/usr/include/libmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:85: recipe for target 'all' failed
make: *** [all] Error 2

in this patch
- correct target name to $OUTPUTgpio-utils.o
- pass OUTPUT to tools/gpio/Makefile
- support cleanup ../gpiogpio-hammer.o

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/gpio/Makefile | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 4665cdb..7f9354a 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -7,7 +7,7 @@ EXTRA_PROGS := ../gpiogpio-event-mon ../gpiogpio-hammer 
../gpiolsgpio
 EXTRA_DIRS := ../gpioinclude/
 EXTRA_OBJS := ../gpiogpio-event-mon-in.o ../gpiogpio-event-mon.o
 EXTRA_OBJS += ../gpiogpio-hammer-in.o ../gpiogpio-utils.o ../gpiolsgpio-in.o
-EXTRA_OBJS += ../gpiolsgpio.o
+EXTRA_OBJS += ../gpiolsgpio.o ../gpiogpio-hammer.o
 
 include ../lib.mk
 
@@ -22,7 +22,7 @@ CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
 LDLIBS += -lmount -I/usr/include/libmount
 
 $(BINARIES):| khdr
-$(BINARIES): ../../../gpio/gpio-utils.o
+$(BINARIES): ../gpiogpio-utils.o
 
-../../../gpio/gpio-utils.o:
-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+../gpiogpio-utils.o:
+   make OUTPUT=$(OUTPUT) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio
-- 
2.7.4



Re: [LKP] [ipc] 61224adcd2: general_protection_fault:#[##]

2018-09-18 Thread Li Zhijian



On 9/18/2018 6:20 PM, David Howells wrote:

Li Zhijian  wrote:


this is not expected.
could you list/home/dhowells/.lkp/cache

final_initrd  initrd-concatenated  lkp/  lkp-x86_64-ad88cb1a437a_.cgz  osimage/

Note that ~/.lkp is a symlink to somewhere that I don't mind clobbering.

Does this assume that I'm running on some particular OS other than Fedora?


sorry, i cannot reproduce your issue on debian and ubuntu

1. please type following command to verify the lkp-src
$ gzip -dc /home/dhowells/.lkp/cache/lkp-x86_64-ad88cb1a437a_.cgz | cpio -t

it should have something like
lizhijian@ivb44:~$ gzip -dc .lkp/cache/lkp-x86_64-ebf5822e1818_.cgz | cpio -t | 
head
lkp
lkp/lkp
lkp/lkp/src
lkp/lkp/src/COPYING
lkp/lkp/src/Gemfile
lkp/lkp/src/Makefile
lkp/lkp/src/README.md
lkp/lkp/src/Rakefile
lkp/lkp/src/_config.yml
lkp/lkp/src/allot

2. remove this file and try again with following changes
lizhijian@ivb44:/lkp-qemu/lkp-tests$ git diff
diff --git a/pack/lkp-src b/pack/lkp-src
index 793084cb..ca8717e9 100755
--- a/pack/lkp-src
+++ b/pack/lkp-src
@@ -1,5 +1,5 @@
 #!/bin/bash
-
+set -x
 LKP_SRC=${LKP_SRC:-/lkp/$USER/src}
 export ARCH=${arch:-x86_64}
 LKP_USER=${LKP_USER:-$USER}



Thanks
 



David


Re: [LKP] [ipc] 61224adcd2: general_protection_fault:#[##]

2018-09-18 Thread Li Zhijian



On 9/18/2018 6:20 PM, David Howells wrote:

Li Zhijian  wrote:


this is not expected.
could you list/home/dhowells/.lkp/cache

final_initrd  initrd-concatenated  lkp/  lkp-x86_64-ad88cb1a437a_.cgz  osimage/

Note that ~/.lkp is a symlink to somewhere that I don't mind clobbering.

Does this assume that I'm running on some particular OS other than Fedora?


sorry, i cannot reproduce your issue on debian and ubuntu

1. please type following command to verify the lkp-src
$ gzip -dc /home/dhowells/.lkp/cache/lkp-x86_64-ad88cb1a437a_.cgz | cpio -t

it should have something like
lizhijian@ivb44:~$ gzip -dc .lkp/cache/lkp-x86_64-ebf5822e1818_.cgz | cpio -t | 
head
lkp
lkp/lkp
lkp/lkp/src
lkp/lkp/src/COPYING
lkp/lkp/src/Gemfile
lkp/lkp/src/Makefile
lkp/lkp/src/README.md
lkp/lkp/src/Rakefile
lkp/lkp/src/_config.yml
lkp/lkp/src/allot

2. remove this file and try again with following changes
lizhijian@ivb44:/lkp-qemu/lkp-tests$ git diff
diff --git a/pack/lkp-src b/pack/lkp-src
index 793084cb..ca8717e9 100755
--- a/pack/lkp-src
+++ b/pack/lkp-src
@@ -1,5 +1,5 @@
 #!/bin/bash
-
+set -x
 LKP_SRC=${LKP_SRC:-/lkp/$USER/src}
 export ARCH=${arch:-x86_64}
 LKP_USER=${LKP_USER:-$USER}



Thanks
 



David


Re: [LKP] [ipc] 61224adcd2: general_protection_fault:#[##]

2018-09-18 Thread Li Zhijian



On 9/18/2018 3:23 PM, David Howells wrote:

Still not sure what I'm meant to be seeing.  Note that there are a number of
"Not found" and "No such file or directory" errors appearing.

I've attached the console log for you.

David
---
warthog>sudo bin/lkp qemu -k /data/fs/linux-next/build2/arch/x86/boot/bzImage 
job-script
make: Entering directory '/data/lkp-tests/bin/event'
gcc-c -o wakeup.o wakeup.c
gcc  -static -o wakeup wakeup.o
rm -f wakeup.o
strip wakeup
make: Leaving directory '/data/lkp-tests/bin/event'
cpio: Cannot open/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or 
directory
cpio: Cannot open/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or 
directory
cpio: Cannot open/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or 
directory
gzip:/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or directory
mv: cannot stat '/home/dhowells/.lkp/cache/lkp-x86_64.cpio.gz': No such file or 
directory
mv: cannot stat '/home/dhowells/.lkp/cache/lkp-x86_64.cgz': No such file or 
directory


this is not expected.
could you list/home/dhowells/.lkp/cache

looks something wrong at below function
lizhijian@haswell-OptiPlex-9020:~/lkp-tests$ vim lkp-exec/qemu +230
230 create_lkp_src_initrd()
231 {
232 if [[ "$kconfig" =~ ^(i386|x86_64)- ]]; then
233 local arch=${kconfig%%-*}
234 else
235 local arch=$(arch)
236 fi
237
238 if [ -d $LKP_SRC/.git ]; then
239 local head_commit=$(cd $LKP_SRC && git rev-list -n1 HEAD)
240 local diff_id=$(cd $LKP_SRC && git diff | git patch-id | 
cut -f1 -d' ')
241 local src_sig=${head_commit:0:12}_${diff_id:0:12}
242 else
243 local src_sig=$(ls -lR $LKP_SRC|md5sum|cut -c1-12)
244 fi
245 lkp_initrd=$CACHE_DIR/lkp-$arch-$src_sig.cgz
246 [[ -f $lkp_initrd ]] || {
247 LKP_USER=$user \
248 $LKP_SRC/sbin/pack -f -a $arch lkp-src
249 mv $CACHE_DIR/lkp-$arch.cgz $lkp_initrd
250 }
251 }


Thanks



Re: [LKP] [ipc] 61224adcd2: general_protection_fault:#[##]

2018-09-18 Thread Li Zhijian



On 9/18/2018 3:23 PM, David Howells wrote:

Still not sure what I'm meant to be seeing.  Note that there are a number of
"Not found" and "No such file or directory" errors appearing.

I've attached the console log for you.

David
---
warthog>sudo bin/lkp qemu -k /data/fs/linux-next/build2/arch/x86/boot/bzImage 
job-script
make: Entering directory '/data/lkp-tests/bin/event'
gcc-c -o wakeup.o wakeup.c
gcc  -static -o wakeup wakeup.o
rm -f wakeup.o
strip wakeup
make: Leaving directory '/data/lkp-tests/bin/event'
cpio: Cannot open/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or 
directory
cpio: Cannot open/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or 
directory
cpio: Cannot open/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or 
directory
gzip:/home/dhowells/.lkp/cache/lkp-x86_64.cpio: No such file or directory
mv: cannot stat '/home/dhowells/.lkp/cache/lkp-x86_64.cpio.gz': No such file or 
directory
mv: cannot stat '/home/dhowells/.lkp/cache/lkp-x86_64.cgz': No such file or 
directory


this is not expected.
could you list/home/dhowells/.lkp/cache

looks something wrong at below function
lizhijian@haswell-OptiPlex-9020:~/lkp-tests$ vim lkp-exec/qemu +230
230 create_lkp_src_initrd()
231 {
232 if [[ "$kconfig" =~ ^(i386|x86_64)- ]]; then
233 local arch=${kconfig%%-*}
234 else
235 local arch=$(arch)
236 fi
237
238 if [ -d $LKP_SRC/.git ]; then
239 local head_commit=$(cd $LKP_SRC && git rev-list -n1 HEAD)
240 local diff_id=$(cd $LKP_SRC && git diff | git patch-id | 
cut -f1 -d' ')
241 local src_sig=${head_commit:0:12}_${diff_id:0:12}
242 else
243 local src_sig=$(ls -lR $LKP_SRC|md5sum|cut -c1-12)
244 fi
245 lkp_initrd=$CACHE_DIR/lkp-$arch-$src_sig.cgz
246 [[ -f $lkp_initrd ]] || {
247 LKP_USER=$user \
248 $LKP_SRC/sbin/pack -f -a $arch lkp-src
249 mv $CACHE_DIR/lkp-$arch.cgz $lkp_initrd
250 }
251 }


Thanks



[PATCH v2] selftests/android: initialize heap_type to avoid compiling warning

2018-07-10 Thread Li Zhijian
root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
make[1]: Entering directory 
'/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_export.c ipcsocket.c 
ionutils.c   -o ionapp_export
ionapp_export.c: In function 'main':
ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
this function [-Wmaybe-uninitialized]
  printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
  ^~~~

CC: Shuah Khan 
CC: Pintu Agarwal 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/android/ion/ionapp_export.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/android/ion/ionapp_export.c 
b/tools/testing/selftests/android/ion/ionapp_export.c
index a944e72..b5fa0a2 100644
--- a/tools/testing/selftests/android/ion/ionapp_export.c
+++ b/tools/testing/selftests/android/ion/ionapp_export.c
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
 
heap_size = 0;
flags = 0;
+   heap_type = ION_HEAP_TYPE_SYSTEM;
 
while ((opt = getopt(argc, argv, "hi:s:")) != -1) {
switch (opt) {
-- 
2.7.4



[PATCH v2] selftests/android: initialize heap_type to avoid compiling warning

2018-07-10 Thread Li Zhijian
root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
make[1]: Entering directory 
'/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_export.c ipcsocket.c 
ionutils.c   -o ionapp_export
ionapp_export.c: In function 'main':
ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
this function [-Wmaybe-uninitialized]
  printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
  ^~~~

CC: Shuah Khan 
CC: Pintu Agarwal 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/android/ion/ionapp_export.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/android/ion/ionapp_export.c 
b/tools/testing/selftests/android/ion/ionapp_export.c
index a944e72..b5fa0a2 100644
--- a/tools/testing/selftests/android/ion/ionapp_export.c
+++ b/tools/testing/selftests/android/ion/ionapp_export.c
@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
 
heap_size = 0;
flags = 0;
+   heap_type = ION_HEAP_TYPE_SYSTEM;
 
while ((opt = getopt(argc, argv, "hi:s:")) != -1) {
switch (opt) {
-- 
2.7.4



Re: [PATCH 0/3] fix selftests compiling errors and warnings

2018-07-10 Thread Li Zhijian




On 07/10/2018 10:08 PM, Shuah Khan wrote:

On 07/10/2018 02:38 AM, Li Zhijian wrote:

ping


On 07/02/2018 11:53 AM, Li Zhijian wrote:

Li Zhijian (3):
    selftests/android: fix compiling error
    selftests/android: initialize heap_type to avoid compiling warning
    selftests/gpio: unset OUTPUT for build tools/gpio

   tools/testing/selftests/android/ion/Makefile    | 5 -
   tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
   tools/testing/selftests/gpio/Makefile   | 2 +-
   3 files changed, 12 insertions(+), 2 deletions(-)





I was away on vacation all of last week. I will review the series.
Anders Roxell is working on making the change at the main Makefile
level to handle the headers dependency.


Good to know this, looking forward it



  I have been waiting to hear
from Maintainers to Ack it.

Once Anders patch goes in, is the first and third patches in this series
needed?


I will have a check once his patch is merged


Thanks



No problems with the second one. I can get that in soon.

thanks,
-- Shuah


.






Re: [PATCH 0/3] fix selftests compiling errors and warnings

2018-07-10 Thread Li Zhijian




On 07/10/2018 10:08 PM, Shuah Khan wrote:

On 07/10/2018 02:38 AM, Li Zhijian wrote:

ping


On 07/02/2018 11:53 AM, Li Zhijian wrote:

Li Zhijian (3):
    selftests/android: fix compiling error
    selftests/android: initialize heap_type to avoid compiling warning
    selftests/gpio: unset OUTPUT for build tools/gpio

   tools/testing/selftests/android/ion/Makefile    | 5 -
   tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
   tools/testing/selftests/gpio/Makefile   | 2 +-
   3 files changed, 12 insertions(+), 2 deletions(-)





I was away on vacation all of last week. I will review the series.
Anders Roxell is working on making the change at the main Makefile
level to handle the headers dependency.


Good to know this, looking forward it



  I have been waiting to hear
from Maintainers to Ack it.

Once Anders patch goes in, is the first and third patches in this series
needed?


I will have a check once his patch is merged


Thanks



No problems with the second one. I can get that in soon.

thanks,
-- Shuah


.






Re: [PATCH 0/3] fix selftests compiling errors and warnings

2018-07-10 Thread Li Zhijian

ping


On 07/02/2018 11:53 AM, Li Zhijian wrote:

Li Zhijian (3):
   selftests/android: fix compiling error
   selftests/android: initialize heap_type to avoid compiling warning
   selftests/gpio: unset OUTPUT for build tools/gpio

  tools/testing/selftests/android/ion/Makefile| 5 -
  tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
  tools/testing/selftests/gpio/Makefile   | 2 +-
  3 files changed, 12 insertions(+), 2 deletions(-)






Re: [PATCH 0/3] fix selftests compiling errors and warnings

2018-07-10 Thread Li Zhijian

ping


On 07/02/2018 11:53 AM, Li Zhijian wrote:

Li Zhijian (3):
   selftests/android: fix compiling error
   selftests/android: initialize heap_type to avoid compiling warning
   selftests/gpio: unset OUTPUT for build tools/gpio

  tools/testing/selftests/android/ion/Makefile| 5 -
  tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
  tools/testing/selftests/gpio/Makefile   | 2 +-
  3 files changed, 12 insertions(+), 2 deletions(-)






[PATCH 0/3] fix selftests compiling errors and warnings

2018-07-01 Thread Li Zhijian


Li Zhijian (3):
  selftests/android: fix compiling error
  selftests/android: initialize heap_type to avoid compiling warning
  selftests/gpio: unset OUTPUT for build tools/gpio

 tools/testing/selftests/android/ion/Makefile| 5 -
 tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
 tools/testing/selftests/gpio/Makefile   | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH 1/3] selftests/android: fix compiling error

2018-07-01 Thread Li Zhijian
lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests/android/ion$
 make
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_export.c ipcsocket.c 
ionutils.c   -o ionapp_export
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_import.c ipcsocket.c 
ionutils.c   -o ionapp_import
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionmap_test.c ipcsocket.c 
ionutils.c   -o ionmap_test
ionmap_test.c:12:27: fatal error: linux/dma-buf.h: No such file or directory
compilation terminated.
: recipe for target 'ionmap_test' failed
make: *** [ionmap_test] Error 1

It requires headers_install to $TOP/usr

CC: Shuah Khan 
CC: Pintu Agarwal 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/android/ion/Makefile | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/android/ion/Makefile 
b/tools/testing/selftests/android/ion/Makefile
index e036952..9f83299 100644
--- a/tools/testing/selftests/android/ion/Makefile
+++ b/tools/testing/selftests/android/ion/Makefile
@@ -4,7 +4,10 @@ CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g
 
 TEST_GEN_FILES := ionapp_export ionapp_import ionmap_test
 
-all: $(TEST_GEN_FILES)
+all: ../../../../../usr/include/linux/dma-buf.h $(TEST_GEN_FILES)
+
+../../../../../usr/include/linux/dma-buf.h:
+   make -C ../../../../../ headers_install INSTALL_HDR_PATH=$(shell 
pwd)/../../../../../usr
 
 $(TEST_GEN_FILES): ipcsocket.c ionutils.c
 
-- 
2.7.4



[PATCH 3/3] selftests/gpio: unset OUTPUT for build tools/gpio

2018-07-01 Thread Li Zhijian
when we execute 'make' to build selftests, the TOP Makefile build gpio like:
selftests$ make ARCH= CROSS_COMPILE= 
OUTPUT=/home/lizj/linux/tools/testing/selftests/gpio -C gpio
...
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h  
-I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -lmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:84: recipe for target 'all' failed
make: *** [all] Error 2

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/gpio/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 1bbb475..e64a11c 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -24,7 +24,7 @@ LDLIBS += -lmount -I/usr/include/libmount
 $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
 
 ../../../gpio/gpio-utils.o:
-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+   make OUTPUT= ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio
 
 ../../../../usr/include/linux/gpio.h:
make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell 
pwd)/../../../../usr/
-- 
2.7.4



[PATCH 0/3] fix selftests compiling errors and warnings

2018-07-01 Thread Li Zhijian


Li Zhijian (3):
  selftests/android: fix compiling error
  selftests/android: initialize heap_type to avoid compiling warning
  selftests/gpio: unset OUTPUT for build tools/gpio

 tools/testing/selftests/android/ion/Makefile| 5 -
 tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
 tools/testing/selftests/gpio/Makefile   | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH 1/3] selftests/android: fix compiling error

2018-07-01 Thread Li Zhijian
lizhijian@haswell-OptiPlex-9020:/home/lizj/linux/tools/testing/selftests/android/ion$
 make
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_export.c ipcsocket.c 
ionutils.c   -o ionapp_export
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_import.c ipcsocket.c 
ionutils.c   -o ionapp_import
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionmap_test.c ipcsocket.c 
ionutils.c   -o ionmap_test
ionmap_test.c:12:27: fatal error: linux/dma-buf.h: No such file or directory
compilation terminated.
: recipe for target 'ionmap_test' failed
make: *** [ionmap_test] Error 1

It requires headers_install to $TOP/usr

CC: Shuah Khan 
CC: Pintu Agarwal 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/android/ion/Makefile | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/android/ion/Makefile 
b/tools/testing/selftests/android/ion/Makefile
index e036952..9f83299 100644
--- a/tools/testing/selftests/android/ion/Makefile
+++ b/tools/testing/selftests/android/ion/Makefile
@@ -4,7 +4,10 @@ CFLAGS := $(CFLAGS) $(INCLUDEDIR) -Wall -O2 -g
 
 TEST_GEN_FILES := ionapp_export ionapp_import ionmap_test
 
-all: $(TEST_GEN_FILES)
+all: ../../../../../usr/include/linux/dma-buf.h $(TEST_GEN_FILES)
+
+../../../../../usr/include/linux/dma-buf.h:
+   make -C ../../../../../ headers_install INSTALL_HDR_PATH=$(shell 
pwd)/../../../../../usr
 
 $(TEST_GEN_FILES): ipcsocket.c ionutils.c
 
-- 
2.7.4



[PATCH 3/3] selftests/gpio: unset OUTPUT for build tools/gpio

2018-07-01 Thread Li Zhijian
when we execute 'make' to build selftests, the TOP Makefile build gpio like:
selftests$ make ARCH= CROSS_COMPILE= 
OUTPUT=/home/lizj/linux/tools/testing/selftests/gpio -C gpio
...
make[2]: Leaving directory '/home/lizj/linux/tools/gpio'
gcc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/gpio-mockup-chardev.c 
../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h  
-I/usr/include/libmount -I/usr/include/blkid -I/usr/include/uuid -lmount -o 
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
: recipe for target 'gpio-mockup-chardev' failed
make[1]: *** [gpio-mockup-chardev] Error 1
make[1]: Leaving directory
'/home/lizj/linux/tools/testing/selftests/gpio'
Makefile:84: recipe for target 'all' failed
make: *** [all] Error 2

CC: Bamvor Jian Zhang 
CC: Bartosz Golaszewski 
CC: Shuah Khan 
CC: linux-g...@vger.kernel.org
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/gpio/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/gpio/Makefile 
b/tools/testing/selftests/gpio/Makefile
index 1bbb475..e64a11c 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -24,7 +24,7 @@ LDLIBS += -lmount -I/usr/include/libmount
 $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
 
 ../../../gpio/gpio-utils.o:
-   make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+   make OUTPUT= ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C 
../../../gpio
 
 ../../../../usr/include/linux/gpio.h:
make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell 
pwd)/../../../../usr/
-- 
2.7.4



[PATCH 2/3] selftests/android: initialize heap_type to avoid compiling warning

2018-07-01 Thread Li Zhijian
root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
make[1]: Entering directory 
'/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_export.c ipcsocket.c 
ionutils.c   -o ionapp_export
ionapp_export.c: In function 'main':
ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
this function [-Wmaybe-uninitialized]
  printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
  ^~~~

CC: Shuah Khan 
CC: Pintu Agarwal 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/android/ion/ionapp_export.c 
b/tools/testing/selftests/android/ion/ionapp_export.c
index a944e72..e3435c2 100644
--- a/tools/testing/selftests/android/ion/ionapp_export.c
+++ b/tools/testing/selftests/android/ion/ionapp_export.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
return -1;
}
 
+   heap_type = -1UL;
heap_size = 0;
flags = 0;
 
@@ -82,6 +83,12 @@ int main(int argc, char *argv[])
}
}
 
+   if (heap_type == -1UL) {
+   printf("heap_type is invalid\n");
+   print_usage(argc, argv);
+   exit(1);
+   }
+
if (heap_size <= 0) {
printf("heap_size cannot be 0\n");
print_usage(argc, argv);
-- 
2.7.4



[PATCH 2/3] selftests/android: initialize heap_type to avoid compiling warning

2018-07-01 Thread Li Zhijian
root@vm-lkp-nex04-8G-7 ~/linux-v4.18-rc2/tools/testing/selftests/android# make
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make 
rule.
make[1]: Entering directory 
'/root/linux-v4.18-rc2/tools/testing/selftests/android/ion'
gcc  -I. -I../../../../../drivers/staging/android/uapi/ 
-I../../../../../usr/include/ -Wall -O2 -gionapp_export.c ipcsocket.c 
ionutils.c   -o ionapp_export
ionapp_export.c: In function 'main':
ionapp_export.c:91:2: warning: 'heap_type' may be used uninitialized in
this function [-Wmaybe-uninitialized]
  printf("heap_type: %ld, heap_size: %ld\n", heap_type, heap_size);
  ^~~~

CC: Shuah Khan 
CC: Pintu Agarwal 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/android/ion/ionapp_export.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tools/testing/selftests/android/ion/ionapp_export.c 
b/tools/testing/selftests/android/ion/ionapp_export.c
index a944e72..e3435c2 100644
--- a/tools/testing/selftests/android/ion/ionapp_export.c
+++ b/tools/testing/selftests/android/ion/ionapp_export.c
@@ -49,6 +49,7 @@ int main(int argc, char *argv[])
return -1;
}
 
+   heap_type = -1UL;
heap_size = 0;
flags = 0;
 
@@ -82,6 +83,12 @@ int main(int argc, char *argv[])
}
}
 
+   if (heap_type == -1UL) {
+   printf("heap_type is invalid\n");
+   print_usage(argc, argv);
+   exit(1);
+   }
+
if (heap_size <= 0) {
printf("heap_size cannot be 0\n");
print_usage(argc, argv);
-- 
2.7.4



Re: [PATCH] perf test record+probe_libc_inet_pton: expect [unknown] for ping as well

2018-06-30 Thread Li Zhijian



On 06/29/2018 11:17 PM, Arnaldo Carvalho de Melo wrote:

Em Thu, Jun 28, 2018 at 03:16:00PM +0800, Li Zhijian escreveu:

On system which has not installed debuginfo of iputils(ping) will fail like:
~/lkp/linux/tools/perf$ sudo ./perf test ping -v

I think that we should try to check if the required debuginfo package is
installed and if so, expect the symbol resolution that takes place in
that case. Other wise expect [unknown], this way we don't leave this
test accepting almost anything in any case.


Looks ping binary in different distros include different symbol.
without this patch, ubuntu 16.04 is good and debian 9 is bad when they both 
have not installed debuginfo for ping.

and then after i installed debuginfo for ping(iputils-ping-dbgsym), test become 
passed as well on debian 9

Debian 9
bofore installing debuginfo, it includes [unknown]
root@vm-lkp-nex04-8G-10 
/usr/src/linux-perf-x86_64-randconfig-w0-06061439-fb43d6cb91ef57d9e58d5f69b423784ff4a4c374/tools/perf#
 ./perf test ping -v
62: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 6324
ping 6341 [000] 4470.361330: probe_libc:inet_pton: (7f9f3900eaa0)
105aa0 inet_pton (/lib/x86_64-linux-gnu/libc-2.24.so)
d52f8 getaddrinfo (/lib/x86_64-linux-gnu/libc-2.24.so)
3ebe [unknown] (/bin/ping)
test child finished with 0

--
after install debuginfo
root@vm-lkp-nex04-8G-10 
/usr/src/linux-perf-x86_64-randconfig-w0-06061439-fb43d6cb91ef57d9e58d5f69b423784ff4a4c374/tools/perf#
 ./perf test ping -v
62: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 6387
ping 6404 [000] 4488.855086: probe_libc:inet_pton: (7fb5bcc7caa0)
105aa0 inet_pton (/lib/x86_64-linux-gnu/libc-2.24.so)
d52f8 getaddrinfo (/lib/x86_64-linux-gnu/libc-2.24.so)
3ebe main (/bin/ping)
test child finished with 0



Thanks




- Arnaldo


63: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 4207
ping 4224 [007] 3034121.295510: probe_libc:inet_pton: (7fedfccb2200)
7fedfccb2200 __GI___inet_pton+0x0 (/lib/x86_64-linux-gnu/libc-2.23.so)
7fedfcc7ad5e getaddrinfo+0xee (/lib/x86_64-linux-gnu/libc-2.23.so)
55e3239a9f4d [unknown] (/bin/ping)
FAIL: expected backtrace entry 3
".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" got "55e3239a9f4d [unknown] 
(/bin/ping)"
test child finished with -1
 end 
probe libc's inet_pton & backtrace it with ping: FAILED!

To be compatible with this system, expects [unknown] as well

Fixes: 7903a7086723 ("perf script: Show symbol offsets by default")
CC: Sandipan Das 
CC: Thomas Richter 
Reported-by: kernel test robot 
Signed-off-by: Li Zhijian 
---
  tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 2630570..ebb6549 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -22,12 +22,12 @@ trace_libc_inet_pton_backtrace() {
eventattr='call-graph=dwarf,max-stack=4'

expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"

expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
-   expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[4]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
*)
eventattr='max-stack=3'
expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$"
-   expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[3]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
esac
  
--

2.7.4


.



--
Best regards.
Li Zhijian (8528)





Re: [PATCH] perf test record+probe_libc_inet_pton: expect [unknown] for ping as well

2018-06-30 Thread Li Zhijian



On 06/29/2018 11:17 PM, Arnaldo Carvalho de Melo wrote:

Em Thu, Jun 28, 2018 at 03:16:00PM +0800, Li Zhijian escreveu:

On system which has not installed debuginfo of iputils(ping) will fail like:
~/lkp/linux/tools/perf$ sudo ./perf test ping -v

I think that we should try to check if the required debuginfo package is
installed and if so, expect the symbol resolution that takes place in
that case. Other wise expect [unknown], this way we don't leave this
test accepting almost anything in any case.


Looks ping binary in different distros include different symbol.
without this patch, ubuntu 16.04 is good and debian 9 is bad when they both 
have not installed debuginfo for ping.

and then after i installed debuginfo for ping(iputils-ping-dbgsym), test become 
passed as well on debian 9

Debian 9
bofore installing debuginfo, it includes [unknown]
root@vm-lkp-nex04-8G-10 
/usr/src/linux-perf-x86_64-randconfig-w0-06061439-fb43d6cb91ef57d9e58d5f69b423784ff4a4c374/tools/perf#
 ./perf test ping -v
62: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 6324
ping 6341 [000] 4470.361330: probe_libc:inet_pton: (7f9f3900eaa0)
105aa0 inet_pton (/lib/x86_64-linux-gnu/libc-2.24.so)
d52f8 getaddrinfo (/lib/x86_64-linux-gnu/libc-2.24.so)
3ebe [unknown] (/bin/ping)
test child finished with 0

--
after install debuginfo
root@vm-lkp-nex04-8G-10 
/usr/src/linux-perf-x86_64-randconfig-w0-06061439-fb43d6cb91ef57d9e58d5f69b423784ff4a4c374/tools/perf#
 ./perf test ping -v
62: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 6387
ping 6404 [000] 4488.855086: probe_libc:inet_pton: (7fb5bcc7caa0)
105aa0 inet_pton (/lib/x86_64-linux-gnu/libc-2.24.so)
d52f8 getaddrinfo (/lib/x86_64-linux-gnu/libc-2.24.so)
3ebe main (/bin/ping)
test child finished with 0



Thanks




- Arnaldo


63: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 4207
ping 4224 [007] 3034121.295510: probe_libc:inet_pton: (7fedfccb2200)
7fedfccb2200 __GI___inet_pton+0x0 (/lib/x86_64-linux-gnu/libc-2.23.so)
7fedfcc7ad5e getaddrinfo+0xee (/lib/x86_64-linux-gnu/libc-2.23.so)
55e3239a9f4d [unknown] (/bin/ping)
FAIL: expected backtrace entry 3
".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" got "55e3239a9f4d [unknown] 
(/bin/ping)"
test child finished with -1
 end 
probe libc's inet_pton & backtrace it with ping: FAILED!

To be compatible with this system, expects [unknown] as well

Fixes: 7903a7086723 ("perf script: Show symbol offsets by default")
CC: Sandipan Das 
CC: Thomas Richter 
Reported-by: kernel test robot 
Signed-off-by: Li Zhijian 
---
  tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 2630570..ebb6549 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -22,12 +22,12 @@ trace_libc_inet_pton_backtrace() {
eventattr='call-graph=dwarf,max-stack=4'

expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"

expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
-   expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[4]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
*)
eventattr='max-stack=3'
expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$"
-   expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[3]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
esac
  
--

2.7.4


.



--
Best regards.
Li Zhijian (8528)





[PATCH] perf test record+probe_libc_inet_pton: expect [unknown] for ping as well

2018-06-28 Thread Li Zhijian
On system which has not installed debuginfo of iputils(ping) will fail like:
~/lkp/linux/tools/perf$ sudo ./perf test ping -v
63: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 4207
ping 4224 [007] 3034121.295510: probe_libc:inet_pton: (7fedfccb2200)
7fedfccb2200 __GI___inet_pton+0x0 (/lib/x86_64-linux-gnu/libc-2.23.so)
7fedfcc7ad5e getaddrinfo+0xee (/lib/x86_64-linux-gnu/libc-2.23.so)
55e3239a9f4d [unknown] (/bin/ping)
FAIL: expected backtrace entry 3
".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" got "55e3239a9f4d [unknown] 
(/bin/ping)"
test child finished with -1
 end 
probe libc's inet_pton & backtrace it with ping: FAILED!

To be compatible with this system, expects [unknown] as well

Fixes: 7903a7086723 ("perf script: Show symbol offsets by default")
CC: Sandipan Das 
CC: Thomas Richter 
Reported-by: kernel test robot 
Signed-off-by: Li Zhijian 
---
 tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 2630570..ebb6549 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -22,12 +22,12 @@ trace_libc_inet_pton_backtrace() {
eventattr='call-graph=dwarf,max-stack=4'

expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"

expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
-   expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[4]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
*)
eventattr='max-stack=3'
expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$"
-   expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[3]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
esac
 
-- 
2.7.4



[PATCH] perf test record+probe_libc_inet_pton: expect [unknown] for ping as well

2018-06-28 Thread Li Zhijian
On system which has not installed debuginfo of iputils(ping) will fail like:
~/lkp/linux/tools/perf$ sudo ./perf test ping -v
63: probe libc's inet_pton & backtrace it with ping   :
--- start ---
test child forked, pid 4207
ping 4224 [007] 3034121.295510: probe_libc:inet_pton: (7fedfccb2200)
7fedfccb2200 __GI___inet_pton+0x0 (/lib/x86_64-linux-gnu/libc-2.23.so)
7fedfcc7ad5e getaddrinfo+0xee (/lib/x86_64-linux-gnu/libc-2.23.so)
55e3239a9f4d [unknown] (/bin/ping)
FAIL: expected backtrace entry 3
".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$" got "55e3239a9f4d [unknown] 
(/bin/ping)"
test child finished with -1
 end 
probe libc's inet_pton & backtrace it with ping: FAILED!

To be compatible with this system, expects [unknown] as well

Fixes: 7903a7086723 ("perf script: Show symbol offsets by default")
CC: Sandipan Das 
CC: Thomas Richter 
Reported-by: kernel test robot 
Signed-off-by: Li Zhijian 
---
 tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 2630570..ebb6549 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -22,12 +22,12 @@ trace_libc_inet_pton_backtrace() {
eventattr='call-graph=dwarf,max-stack=4'

expected[2]="gaih_inet.*\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"

expected[3]="(__GI_)?getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc|inlined\)$"
-   expected[4]="main\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[4]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
*)
eventattr='max-stack=3'
expected[2]="getaddrinfo\+0x[[:xdigit:]]+[[:space:]]\($libc\)$"
-   expected[3]=".*\+0x[[:xdigit:]]+[[:space:]]\(.*/bin/ping.*\)$"
+   
expected[3]=".*(\+0x[[:xdigit:]]|\[unknown\])+[[:space:]]\(.*/bin/ping.*\)$"
;;
esac
 
-- 
2.7.4



Re: [PATCH] x86/entry/64/compat: Fix "x86/entry/64/compat: Preserve r8-r11 in int $0x80"

2018-06-27 Thread Li Zhijian



On 6/27/2018 1:45 PM, Andy Lutomirski wrote:

Commit 8bb2610bc496 ("x86/entry/64/compat: Preserve r8-r11 in int
$0x80") was busted.  My original patch had a minor conflict with
some of the nospec changes.  git apply is very clever and silently
accepted the patch by making the same changes to a different
function in the same file.  There was obviously a huge offset, but
git apply for some reason doesn't feel any need to say so.

Move the changes to the correct function.  Now the
test_syscall_vdso_32 selftests passes.

If anyone cares to observe the original problem, try applying the
patch at
https://lore.kernel.org/lkml/d4c4d9985fbe64f8c9e19291886453914b48caee.1523975710.git.l...@kernel.org/raw
to the kernel at 316d097c4cd4e7f2ef50c40cff2db266593c4ec4.  git am and
git apply accept the patch without any complaints at all.  patch -p1
at least prints out a message about the huge offset.

Reported-by: zhijianx...@intel.com
Fixes: 8bb2610bc496 ("x86/entry/64/compat: Preserve r8-r11 in int $0x80")
Cc: sta...@vger.kernel.org
Signed-off-by: Andy Lutomirski 


Tested-by: Li Zhijian 



---
  arch/x86/entry/entry_64_compat.S | 16 
  1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 9de7f1e1dede..7d0df78db727 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -84,13 +84,13 @@ ENTRY(entry_SYSENTER_compat)
pushq   %rdx/* pt_regs->dx */
pushq   %rcx/* pt_regs->cx */
pushq   $-ENOSYS/* pt_regs->ax */
-   pushq   %r8 /* pt_regs->r8 */
+   pushq   $0  /* pt_regs->r8  = 0 */
xorl%r8d, %r8d  /* nospec   r8 */
-   pushq   %r9 /* pt_regs->r9 */
+   pushq   $0  /* pt_regs->r9  = 0 */
xorl%r9d, %r9d  /* nospec   r9 */
-   pushq   %r10/* pt_regs->r10 */
+   pushq   $0  /* pt_regs->r10 = 0 */
xorl%r10d, %r10d/* nospec   r10 */
-   pushq   %r11/* pt_regs->r11 */
+   pushq   $0  /* pt_regs->r11 = 0 */
xorl%r11d, %r11d/* nospec   r11 */
pushq   %rbx/* pt_regs->rbx */
xorl%ebx, %ebx  /* nospec   rbx */
@@ -374,13 +374,13 @@ ENTRY(entry_INT80_compat)
pushq   %rcx/* pt_regs->cx */
xorl%ecx, %ecx  /* nospec   cx */
pushq   $-ENOSYS/* pt_regs->ax */
-   pushq   $0  /* pt_regs->r8  = 0 */
+   pushq   %r8 /* pt_regs->r8 */
xorl%r8d, %r8d  /* nospec   r8 */
-   pushq   $0  /* pt_regs->r9  = 0 */
+   pushq   %r9 /* pt_regs->r9 */
xorl%r9d, %r9d  /* nospec   r9 */
-   pushq   $0  /* pt_regs->r10 = 0 */
+   pushq   %r10/* pt_regs->r10*/
xorl%r10d, %r10d/* nospec   r10 */
-   pushq   $0  /* pt_regs->r11 = 0 */
+   pushq   %r11/* pt_regs->r11 */
xorl%r11d, %r11d/* nospec   r11 */
pushq   %rbx/* pt_regs->rbx */
xorl%ebx, %ebx  /* nospec   rbx */


Re: [PATCH] x86/entry/64/compat: Fix "x86/entry/64/compat: Preserve r8-r11 in int $0x80"

2018-06-27 Thread Li Zhijian



On 6/27/2018 1:45 PM, Andy Lutomirski wrote:

Commit 8bb2610bc496 ("x86/entry/64/compat: Preserve r8-r11 in int
$0x80") was busted.  My original patch had a minor conflict with
some of the nospec changes.  git apply is very clever and silently
accepted the patch by making the same changes to a different
function in the same file.  There was obviously a huge offset, but
git apply for some reason doesn't feel any need to say so.

Move the changes to the correct function.  Now the
test_syscall_vdso_32 selftests passes.

If anyone cares to observe the original problem, try applying the
patch at
https://lore.kernel.org/lkml/d4c4d9985fbe64f8c9e19291886453914b48caee.1523975710.git.l...@kernel.org/raw
to the kernel at 316d097c4cd4e7f2ef50c40cff2db266593c4ec4.  git am and
git apply accept the patch without any complaints at all.  patch -p1
at least prints out a message about the huge offset.

Reported-by: zhijianx...@intel.com
Fixes: 8bb2610bc496 ("x86/entry/64/compat: Preserve r8-r11 in int $0x80")
Cc: sta...@vger.kernel.org
Signed-off-by: Andy Lutomirski 


Tested-by: Li Zhijian 



---
  arch/x86/entry/entry_64_compat.S | 16 
  1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/entry_64_compat.S b/arch/x86/entry/entry_64_compat.S
index 9de7f1e1dede..7d0df78db727 100644
--- a/arch/x86/entry/entry_64_compat.S
+++ b/arch/x86/entry/entry_64_compat.S
@@ -84,13 +84,13 @@ ENTRY(entry_SYSENTER_compat)
pushq   %rdx/* pt_regs->dx */
pushq   %rcx/* pt_regs->cx */
pushq   $-ENOSYS/* pt_regs->ax */
-   pushq   %r8 /* pt_regs->r8 */
+   pushq   $0  /* pt_regs->r8  = 0 */
xorl%r8d, %r8d  /* nospec   r8 */
-   pushq   %r9 /* pt_regs->r9 */
+   pushq   $0  /* pt_regs->r9  = 0 */
xorl%r9d, %r9d  /* nospec   r9 */
-   pushq   %r10/* pt_regs->r10 */
+   pushq   $0  /* pt_regs->r10 = 0 */
xorl%r10d, %r10d/* nospec   r10 */
-   pushq   %r11/* pt_regs->r11 */
+   pushq   $0  /* pt_regs->r11 = 0 */
xorl%r11d, %r11d/* nospec   r11 */
pushq   %rbx/* pt_regs->rbx */
xorl%ebx, %ebx  /* nospec   rbx */
@@ -374,13 +374,13 @@ ENTRY(entry_INT80_compat)
pushq   %rcx/* pt_regs->cx */
xorl%ecx, %ecx  /* nospec   cx */
pushq   $-ENOSYS/* pt_regs->ax */
-   pushq   $0  /* pt_regs->r8  = 0 */
+   pushq   %r8 /* pt_regs->r8 */
xorl%r8d, %r8d  /* nospec   r8 */
-   pushq   $0  /* pt_regs->r9  = 0 */
+   pushq   %r9 /* pt_regs->r9 */
xorl%r9d, %r9d  /* nospec   r9 */
-   pushq   $0  /* pt_regs->r10 = 0 */
+   pushq   %r10/* pt_regs->r10*/
xorl%r10d, %r10d/* nospec   r10 */
-   pushq   $0  /* pt_regs->r11 = 0 */
+   pushq   %r11/* pt_regs->r11 */
xorl%r11d, %r11d/* nospec   r11 */
pushq   %rbx/* pt_regs->rbx */
xorl%ebx, %ebx  /* nospec   rbx */


test_syscall_vdso_32 [FAIL]

2018-06-25 Thread Li Zhijian

Hi

Intel 0Day noticed that test_syscall_vdso_32 failed since 
8bb2610bc4967f19672444a7b0407367f1540028(x86/entry/64/compat: Preserve r8-r11 
in int $0x80)

2018-06-25 14:23:00 make run_tests -C x86
make: Entering directory 
'/usr/src/linux-selftests-x86_64-rhel-7.2-8bb2610bc4967f19672444a7b0407367f1540028/tools/testing/selftests/x86'
gcc -m32 -o 
/usr/src/linux-selftests-x86_64-rhel-7.2-8bb2610bc4967f19672444a7b0407367f1540028/tools/testing/selftests/x86/test_syscall_vdso_32
 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 
test_syscall_vdso.c thunks_32.S -lrt -ldl -lm
TAP version 13
selftests: test_syscall_vdso_32

[RUN]   Executing 6-argument 32-bit syscall via VDSO
[WARN]  Flags before=00200ed7 id 0 00 o d i s z 0 a 0 p 1 c
[WARN]  Flags  after=00200606 id 0 00 d i 0 0 p 1
[WARN]  Flags change=08d1 0 00 o s z 0 a 0 0 c
[OK]Arguments are preserved across syscall
[NOTE]  R11 has changed:00200606 - assuming clobbered by SYSRET insn
[OK]R8..R15 did not leak kernel data
[RUN]   Executing 6-argument 32-bit syscall via INT 80
[OK]Arguments are preserved across syscall
[FAIL]  R8 has changed:
[FAIL]  R9 has changed:
[FAIL]  R10 has changed:
[FAIL]  R11 has changed:
[RUN]   Executing 6-argument 32-bit syscall via VDSO
[WARN]  Flags before=00200ed7 id 0 00 o d i s z 0 a 0 p 1 c
[WARN]  Flags  after=00200606 id 0 00 d i 0 0 p 1
[WARN]  Flags change=08d1 0 00 o s z 0 a 0 0 c
[OK]Arguments are preserved across syscall
[NOTE]  R11 has changed:00200606 - assuming clobbered by SYSRET insn
[OK]R8..R15 did not leak kernel data
[RUN]   Executing 6-argument 32-bit syscall via INT 80
[OK]Arguments are preserved across syscall
[FAIL]  R8 has changed:
[FAIL]  R9 has changed:
[FAIL]  R10 has changed:
[FAIL]  R11 has changed:
[RUN]   Running tests under ptrace
not ok 1..1 selftests:  test_syscall_vdso_32 [FAIL]
make: Leaving directory 
'/usr/src/linux-selftests-x86_64-rhel-7.2-8bb2610bc4967f19672444a7b0407367f1540028/tools/testing/selftests/x86'

This commit changed the testcase expected behavior, but looks it doesn't work 
as expected.
so want to consult whether 0Day missed something(special configurations) to 
this case ?

if more details are needed, please let me know.


Thanks



test_syscall_vdso_32 [FAIL]

2018-06-25 Thread Li Zhijian

Hi

Intel 0Day noticed that test_syscall_vdso_32 failed since 
8bb2610bc4967f19672444a7b0407367f1540028(x86/entry/64/compat: Preserve r8-r11 
in int $0x80)

2018-06-25 14:23:00 make run_tests -C x86
make: Entering directory 
'/usr/src/linux-selftests-x86_64-rhel-7.2-8bb2610bc4967f19672444a7b0407367f1540028/tools/testing/selftests/x86'
gcc -m32 -o 
/usr/src/linux-selftests-x86_64-rhel-7.2-8bb2610bc4967f19672444a7b0407367f1540028/tools/testing/selftests/x86/test_syscall_vdso_32
 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 
test_syscall_vdso.c thunks_32.S -lrt -ldl -lm
TAP version 13
selftests: test_syscall_vdso_32

[RUN]   Executing 6-argument 32-bit syscall via VDSO
[WARN]  Flags before=00200ed7 id 0 00 o d i s z 0 a 0 p 1 c
[WARN]  Flags  after=00200606 id 0 00 d i 0 0 p 1
[WARN]  Flags change=08d1 0 00 o s z 0 a 0 0 c
[OK]Arguments are preserved across syscall
[NOTE]  R11 has changed:00200606 - assuming clobbered by SYSRET insn
[OK]R8..R15 did not leak kernel data
[RUN]   Executing 6-argument 32-bit syscall via INT 80
[OK]Arguments are preserved across syscall
[FAIL]  R8 has changed:
[FAIL]  R9 has changed:
[FAIL]  R10 has changed:
[FAIL]  R11 has changed:
[RUN]   Executing 6-argument 32-bit syscall via VDSO
[WARN]  Flags before=00200ed7 id 0 00 o d i s z 0 a 0 p 1 c
[WARN]  Flags  after=00200606 id 0 00 d i 0 0 p 1
[WARN]  Flags change=08d1 0 00 o s z 0 a 0 0 c
[OK]Arguments are preserved across syscall
[NOTE]  R11 has changed:00200606 - assuming clobbered by SYSRET insn
[OK]R8..R15 did not leak kernel data
[RUN]   Executing 6-argument 32-bit syscall via INT 80
[OK]Arguments are preserved across syscall
[FAIL]  R8 has changed:
[FAIL]  R9 has changed:
[FAIL]  R10 has changed:
[FAIL]  R11 has changed:
[RUN]   Running tests under ptrace
not ok 1..1 selftests:  test_syscall_vdso_32 [FAIL]
make: Leaving directory 
'/usr/src/linux-selftests-x86_64-rhel-7.2-8bb2610bc4967f19672444a7b0407367f1540028/tools/testing/selftests/x86'

This commit changed the testcase expected behavior, but looks it doesn't work 
as expected.
so want to consult whether 0Day missed something(special configurations) to 
this case ?

if more details are needed, please let me know.


Thanks



Re: [PATCH v2] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian

The input file is from
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf/tests/shell$ grep libc= 
-A1  record+probe_libc_inet_pton.sh
libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254

It mostly points to a striped libc.so(the runtime library)
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf/tests/shell$ grep -w 
libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g'
/lib/x86_64-linux-gnu/libc-2.23.so

Although we can get the expected symbol from the debug library, it still 
doesn't work for this case.

Thanks
Zhijian


On 05/10/2018 05:41 AM, Kim Phillips wrote:

On Wed, 9 May 2018 15:45:29 +0800
Li Zhijian <lizhij...@cn.fujitsu.com> wrote:


On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

I'm wondering if that is because libc6-dbg isn't installed?:

ubuntu$ nm -g /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.26.so | grep inet_pton
00136340 W inet_pton
00136010 T __inet_pton_length

Kim


.






Re: [PATCH v2] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian

The input file is from
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf/tests/shell$ grep libc= 
-A1  record+probe_libc_inet_pton.sh
libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254

It mostly points to a striped libc.so(the runtime library)
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf/tests/shell$ grep -w 
libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g'
/lib/x86_64-linux-gnu/libc-2.23.so

Although we can get the expected symbol from the debug library, it still 
doesn't work for this case.

Thanks
Zhijian


On 05/10/2018 05:41 AM, Kim Phillips wrote:

On Wed, 9 May 2018 15:45:29 +0800
Li Zhijian  wrote:


On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

I'm wondering if that is because libc6-dbg isn't installed?:

ubuntu$ nm -g /usr/lib/debug/lib/x86_64-linux-gnu/libc-2.26.so | grep inet_pton
00136340 W inet_pton
00136010 T __inet_pton_length

Kim


.






[PATCH v2] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian
On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
 List symbols in [file(s)] (a.out by default).
 The options are:
...snip...
  -D, --dynamic  Display dynamic symbols instead of normal symbols
  --defined-only Display only defined symbols
  -e (ignored)
  -f, --format=FORMATUse the output format FORMAT.  FORMAT can be `bsd',
   `sysv' or `posix'.  The default is `bsd'
  -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter <tmri...@linux.vnet.ibm.com>
CC: Arnaldo Carvalho de Melo <a...@redhat.com>
Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
 tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 016882d..deec366 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
 . $(dirname $0)/lib/probe.sh
 
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
 
 trace_libc_inet_pton_backtrace() {
idx=0
-- 
2.7.4





[PATCH v2] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian
On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
 List symbols in [file(s)] (a.out by default).
 The options are:
...snip...
  -D, --dynamic  Display dynamic symbols instead of normal symbols
  --defined-only Display only defined symbols
  -e (ignored)
  -f, --format=FORMATUse the output format FORMAT.  FORMAT can be `bsd',
   `sysv' or `posix'.  The default is `bsd'
  -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter 
CC: Arnaldo Carvalho de Melo 
Signed-off-by: Li Zhijian 
---
 tools/perf/tests/shell/record+probe_libc_inet_pton.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
index 016882d..deec366 100755
--- a/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/record+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
 . $(dirname $0)/lib/probe.sh
 
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
 
 trace_libc_inet_pton_backtrace() {
idx=0
-- 
2.7.4





Re: [PATCH] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian

Sorry, just noticed this path is out-of-date
i will rebase it


On 05/09/2018 03:36 PM, Li Zhijian wrote:

ping


On 12/27/2017 04:50 PM, Li Zhijian wrote:

On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
  List symbols in [file(s)] (a.out by default).
  The options are:
...snip...
   -D, --dynamic  Display dynamic symbols instead of normal symbols
   --defined-only Display only defined symbols
   -e (ignored)
   -f, --format=FORMAT    Use the output format FORMAT.  FORMAT can be `bsd',
    `sysv' or `posix'.  The default is `bsd'
   -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter <tmri...@linux.vnet.ibm.com>
CC: Arnaldo Carvalho de Melo <a...@redhat.com>
Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
  tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 8b3da21..f939bd6 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
  . $(dirname $0)/lib/probe.sh
    libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
    trace_libc_inet_pton_backtrace() {
  idx=0


--
Best regards.
Li Zhijian (8528)





Re: [PATCH] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian

Sorry, just noticed this path is out-of-date
i will rebase it


On 05/09/2018 03:36 PM, Li Zhijian wrote:

ping


On 12/27/2017 04:50 PM, Li Zhijian wrote:

On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
  List symbols in [file(s)] (a.out by default).
  The options are:
...snip...
   -D, --dynamic  Display dynamic symbols instead of normal symbols
   --defined-only Display only defined symbols
   -e (ignored)
   -f, --format=FORMAT    Use the output format FORMAT.  FORMAT can be `bsd',
    `sysv' or `posix'.  The default is `bsd'
   -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter 
CC: Arnaldo Carvalho de Melo 
Signed-off-by: Li Zhijian 
---
  tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 8b3da21..f939bd6 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
  . $(dirname $0)/lib/probe.sh
    libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
    trace_libc_inet_pton_backtrace() {
  idx=0


--
Best regards.
Li Zhijian (8528)





Re: [PATCH] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian

ping


On 12/27/2017 04:50 PM, Li Zhijian wrote:

On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
  List symbols in [file(s)] (a.out by default).
  The options are:
...snip...
   -D, --dynamic  Display dynamic symbols instead of normal symbols
   --defined-only Display only defined symbols
   -e (ignored)
   -f, --format=FORMATUse the output format FORMAT.  FORMAT can be `bsd',
`sysv' or `posix'.  The default is `bsd'
   -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter <tmri...@linux.vnet.ibm.com>
CC: Arnaldo Carvalho de Melo <a...@redhat.com>
Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
  tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 8b3da21..f939bd6 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
  . $(dirname $0)/lib/probe.sh
  
  libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')

-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
  
  trace_libc_inet_pton_backtrace() {

idx=0





Re: [PATCH] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2018-05-09 Thread Li Zhijian

ping


On 12/27/2017 04:50 PM, Li Zhijian wrote:

On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
  List symbols in [file(s)] (a.out by default).
  The options are:
...snip...
   -D, --dynamic  Display dynamic symbols instead of normal symbols
   --defined-only Display only defined symbols
   -e (ignored)
   -f, --format=FORMATUse the output format FORMAT.  FORMAT can be `bsd',
`sysv' or `posix'.  The default is `bsd'
   -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter 
CC: Arnaldo Carvalho de Melo 
Signed-off-by: Li Zhijian 
---
  tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 8b3da21..f939bd6 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
  . $(dirname $0)/lib/probe.sh
  
  libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 's/.*[[:space:]](\/.*)/\1/g')

-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
  
  trace_libc_inet_pton_backtrace() {

idx=0





[PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'

2018-05-08 Thread Li Zhijian
pkey_get() and pkey_set() are implemented since glibc-2.27, here just
rename pkey_get|pkey_set to _pkey_get|_pkey_set simply

the compiling errors are like:

protection_keys.c:399:5: error: conflicting types for 'pkey_get'
 u32 pkey_get(int pkey, unsigned long flags)
 ^
In file included from /usr/include/bits/mman-linux.h:115:0,
 from /usr/include/bits/mman.h:45,
 from /usr/include/sys/mman.h:41,
 from protection_keys.c:37:
/usr/include/bits/mman-shared.h:64:5: note: previous declaration of 'pkey_get' 
was here
 int pkey_get (int __key) __THROW;
 ^
protection_keys.c:421:5: error: conflicting types for 'pkey_set'
 int pkey_set(int pkey, unsigned long rights, unsigned long flags)
 ^
In file included from /usr/include/bits/mman-linux.h:115:0,
 from /usr/include/bits/mman.h:45,
 from /usr/include/sys/mman.h:41,
 from protection_keys.c:37:
/usr/include/bits/mman-shared.h:60:5: note: previous declaration of 'pkey_set' 
was here
 int pkey_set (int __key, unsigned int __access_rights) __THROW;
 ^


Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
 tools/testing/selftests/x86/protection_keys.c | 32 +++
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/x86/protection_keys.c 
b/tools/testing/selftests/x86/protection_keys.c
index 757bb16..ccbd81f 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -397,10 +397,14 @@ pid_t fork_lazy_child(void)
return forkret;
 }
 
-#define PKEY_DISABLE_ACCESS0x1
-#define PKEY_DISABLE_WRITE 0x2
+#ifndef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS0x1
+#endif
+#ifndef PKEY_DISABLE_WRITE
+# define PKEY_DISABLE_WRITE 0x2
+#endif
 
-u32 pkey_get(int pkey, unsigned long flags)
+u32 _pkey_get(int pkey, unsigned long flags)
 {
u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
u32 pkru = __rdpkru();
@@ -422,7 +426,7 @@ u32 pkey_get(int pkey, unsigned long flags)
return masked_pkru;
 }
 
-int pkey_set(int pkey, unsigned long rights, unsigned long flags)
+int _pkey_set(int pkey, unsigned long rights, unsigned long flags)
 {
u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
u32 old_pkru = __rdpkru();
@@ -456,15 +460,15 @@ void pkey_disable_set(int pkey, int flags)
pkey, flags);
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
 
-   pkey_rights = pkey_get(pkey, syscall_flags);
+   pkey_rights = _pkey_get(pkey, syscall_flags);
 
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
pkey_assert(pkey_rights >= 0);
 
pkey_rights |= flags;
 
-   ret = pkey_set(pkey, pkey_rights, syscall_flags);
+   ret = _pkey_set(pkey, pkey_rights, syscall_flags);
assert(!ret);
/*pkru and flags have the same format */
shadow_pkru |= flags << (pkey * 2);
@@ -472,8 +476,8 @@ void pkey_disable_set(int pkey, int flags)
 
pkey_assert(ret >= 0);
 
-   pkey_rights = pkey_get(pkey, syscall_flags);
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   pkey_rights = _pkey_get(pkey, syscall_flags);
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
 
dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());
@@ -487,24 +491,24 @@ void pkey_disable_clear(int pkey, int flags)
 {
unsigned long syscall_flags = 0;
int ret;
-   int pkey_rights = pkey_get(pkey, syscall_flags);
+   int pkey_rights = _pkey_get(pkey, syscall_flags);
u32 orig_pkru = rdpkru();
 
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
 
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
pkey_assert(pkey_rights >= 0);
 
pkey_rights |= flags;
 
-   ret = pkey_set(pkey, pkey_rights, 0);
+   ret = _pkey_set(pkey, pkey_rights, 0);
/* pkru and flags have the same format */
shadow_pkru &= ~(flags << (pkey * 2));
pkey_assert(ret >= 0);
 
-   pkey_rights = pkey_get(pkey, syscall_flags);
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   pkey_rights = _pkey_get(pkey, syscall_flags);
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
 
dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());
-- 
2.7.4





[PATCH 2/2] tools/testing/selftests/x86: fix error: conflicting types for 'pkey_get|pkey_set'

2018-05-08 Thread Li Zhijian
pkey_get() and pkey_set() are implemented since glibc-2.27, here just
rename pkey_get|pkey_set to _pkey_get|_pkey_set simply

the compiling errors are like:

protection_keys.c:399:5: error: conflicting types for 'pkey_get'
 u32 pkey_get(int pkey, unsigned long flags)
 ^
In file included from /usr/include/bits/mman-linux.h:115:0,
 from /usr/include/bits/mman.h:45,
 from /usr/include/sys/mman.h:41,
 from protection_keys.c:37:
/usr/include/bits/mman-shared.h:64:5: note: previous declaration of 'pkey_get' 
was here
 int pkey_get (int __key) __THROW;
 ^
protection_keys.c:421:5: error: conflicting types for 'pkey_set'
 int pkey_set(int pkey, unsigned long rights, unsigned long flags)
 ^
In file included from /usr/include/bits/mman-linux.h:115:0,
 from /usr/include/bits/mman.h:45,
 from /usr/include/sys/mman.h:41,
 from protection_keys.c:37:
/usr/include/bits/mman-shared.h:60:5: note: previous declaration of 'pkey_set' 
was here
 int pkey_set (int __key, unsigned int __access_rights) __THROW;
 ^


Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/x86/protection_keys.c | 32 +++
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/tools/testing/selftests/x86/protection_keys.c 
b/tools/testing/selftests/x86/protection_keys.c
index 757bb16..ccbd81f 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -397,10 +397,14 @@ pid_t fork_lazy_child(void)
return forkret;
 }
 
-#define PKEY_DISABLE_ACCESS0x1
-#define PKEY_DISABLE_WRITE 0x2
+#ifndef PKEY_DISABLE_ACCESS
+# define PKEY_DISABLE_ACCESS0x1
+#endif
+#ifndef PKEY_DISABLE_WRITE
+# define PKEY_DISABLE_WRITE 0x2
+#endif
 
-u32 pkey_get(int pkey, unsigned long flags)
+u32 _pkey_get(int pkey, unsigned long flags)
 {
u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
u32 pkru = __rdpkru();
@@ -422,7 +426,7 @@ u32 pkey_get(int pkey, unsigned long flags)
return masked_pkru;
 }
 
-int pkey_set(int pkey, unsigned long rights, unsigned long flags)
+int _pkey_set(int pkey, unsigned long rights, unsigned long flags)
 {
u32 mask = (PKEY_DISABLE_ACCESS|PKEY_DISABLE_WRITE);
u32 old_pkru = __rdpkru();
@@ -456,15 +460,15 @@ void pkey_disable_set(int pkey, int flags)
pkey, flags);
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
 
-   pkey_rights = pkey_get(pkey, syscall_flags);
+   pkey_rights = _pkey_get(pkey, syscall_flags);
 
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
pkey_assert(pkey_rights >= 0);
 
pkey_rights |= flags;
 
-   ret = pkey_set(pkey, pkey_rights, syscall_flags);
+   ret = _pkey_set(pkey, pkey_rights, syscall_flags);
assert(!ret);
/*pkru and flags have the same format */
shadow_pkru |= flags << (pkey * 2);
@@ -472,8 +476,8 @@ void pkey_disable_set(int pkey, int flags)
 
pkey_assert(ret >= 0);
 
-   pkey_rights = pkey_get(pkey, syscall_flags);
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   pkey_rights = _pkey_get(pkey, syscall_flags);
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
 
dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());
@@ -487,24 +491,24 @@ void pkey_disable_clear(int pkey, int flags)
 {
unsigned long syscall_flags = 0;
int ret;
-   int pkey_rights = pkey_get(pkey, syscall_flags);
+   int pkey_rights = _pkey_get(pkey, syscall_flags);
u32 orig_pkru = rdpkru();
 
pkey_assert(flags & (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE));
 
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
pkey_assert(pkey_rights >= 0);
 
pkey_rights |= flags;
 
-   ret = pkey_set(pkey, pkey_rights, 0);
+   ret = _pkey_set(pkey, pkey_rights, 0);
/* pkru and flags have the same format */
shadow_pkru &= ~(flags << (pkey * 2));
pkey_assert(ret >= 0);
 
-   pkey_rights = pkey_get(pkey, syscall_flags);
-   dprintf1("%s(%d) pkey_get(%d): %x\n", __func__,
+   pkey_rights = _pkey_get(pkey, syscall_flags);
+   dprintf1("%s(%d) _pkey_get(%d): %x\n", __func__,
pkey, pkey, pkey_rights);
 
dprintf1("%s(%d) pkru: 0x%x\n", __func__, pkey, rdpkru());
-- 
2.7.4





[PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined

2018-05-08 Thread Li Zhijian
SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27

fix the following issue:
---
root@vm-lkp-nex04-4G-5 
/usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86#
 make
gcc -m32 -o 
/usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86/protection_keys_32
 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 
protection_keys.c -lrt -ldl -lm
gcc -m64 -o 
/usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86/protection_keys_64
 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 
protection_keys.c -lrt -ldl
protection_keys.c:228:0: warning: "SEGV_BNDERR" redefined
 #define SEGV_BNDERR 3  /* failed address bound checks */
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/bits/siginfo-consts.h:117:0: note: this is the location of the 
previous definition
 #  define SEGV_BNDERR SEGV_BNDERR
 ^
protection_keys.c:229:0: warning: "SEGV_PKUERR" redefined
 #define SEGV_PKUERR 4
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/bits/siginfo-consts.h:119:0: note: this is the location of the 
previous definition
 #  define SEGV_PKUERR SEGV_PKUERR
 ^
protection_keys.c:228:0: warning: "SEGV_BNDERR" redefined
 #define SEGV_BNDERR 3  /* failed address bound checks */
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h:117:0: note: this is the 
location of the previous definition
 #  define SEGV_BNDERR SEGV_BNDERR
 ^
protection_keys.c:229:0: warning: "SEGV_PKUERR" redefined
 #define SEGV_PKUERR 4
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h:119:0: note: this is the 
location of the previous definition
 #  define SEGV_PKUERR SEGV_PKUERR
 ^
---

Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
 tools/testing/selftests/x86/protection_keys.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/protection_keys.c 
b/tools/testing/selftests/x86/protection_keys.c
index f15aa5a..757bb16 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -225,8 +225,12 @@ void dump_mem(void *dumpme, int len_bytes)
}
 }
 
-#define SEGV_BNDERR 3  /* failed address bound checks */
-#define SEGV_PKUERR 4
+#ifndef SEGV_BNDERR
+# define SEGV_BNDERR 3  /* failed address bound checks */
+#endif
+#ifndef SEGV_PKUERR
+# define SEGV_PKUERR 4
+#endif
 
 static char *si_code_str(int si_code)
 {
-- 
2.7.4





[PATCH 1/2] tools/testing/selftests/x86: fix warning: "SEGV_PKUERR|SEGV_BNDERR" redefined

2018-05-08 Thread Li Zhijian
SEGV_PKUERR and SEGV_BNDERR are defined since glibc-2.27

fix the following issue:
---
root@vm-lkp-nex04-4G-5 
/usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86#
 make
gcc -m32 -o 
/usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86/protection_keys_32
 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 
protection_keys.c -lrt -ldl -lm
gcc -m64 -o 
/usr/src/linux-selftests-x86_64-rhel-7.2-75bc37fefc4471e718ba8e651aa74673d4e0a9eb/tools/testing/selftests/x86/protection_keys_64
 -O2 -g -std=gnu99 -pthread -Wall -no-pie -DCAN_BUILD_32 -DCAN_BUILD_64 
protection_keys.c -lrt -ldl
protection_keys.c:228:0: warning: "SEGV_BNDERR" redefined
 #define SEGV_BNDERR 3  /* failed address bound checks */
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/bits/siginfo-consts.h:117:0: note: this is the location of the 
previous definition
 #  define SEGV_BNDERR SEGV_BNDERR
 ^
protection_keys.c:229:0: warning: "SEGV_PKUERR" redefined
 #define SEGV_PKUERR 4
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/bits/siginfo-consts.h:119:0: note: this is the location of the 
previous definition
 #  define SEGV_PKUERR SEGV_PKUERR
 ^
protection_keys.c:228:0: warning: "SEGV_BNDERR" redefined
 #define SEGV_BNDERR 3  /* failed address bound checks */
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h:117:0: note: this is the 
location of the previous definition
 #  define SEGV_BNDERR SEGV_BNDERR
 ^
protection_keys.c:229:0: warning: "SEGV_PKUERR" redefined
 #define SEGV_PKUERR 4
 ^
In file included from /usr/include/signal.h:58:0,
 from protection_keys.c:33:
/usr/include/x86_64-linux-gnu/bits/siginfo-consts.h:119:0: note: this is the 
location of the previous definition
 #  define SEGV_PKUERR SEGV_PKUERR
 ^
---

Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/x86/protection_keys.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/x86/protection_keys.c 
b/tools/testing/selftests/x86/protection_keys.c
index f15aa5a..757bb16 100644
--- a/tools/testing/selftests/x86/protection_keys.c
+++ b/tools/testing/selftests/x86/protection_keys.c
@@ -225,8 +225,12 @@ void dump_mem(void *dumpme, int len_bytes)
}
 }
 
-#define SEGV_BNDERR 3  /* failed address bound checks */
-#define SEGV_PKUERR 4
+#ifndef SEGV_BNDERR
+# define SEGV_BNDERR 3  /* failed address bound checks */
+#endif
+#ifndef SEGV_PKUERR
+# define SEGV_PKUERR 4
+#endif
 
 static char *si_code_str(int si_code)
 {
-- 
2.7.4





Re: kernel_selftests.x86.mpx-mini-test_32.fail on skylake platform

2018-03-22 Thread Li Zhijian

Sorry to reply so late.

On 3/13/2018 1:34 AM, Dave Hansen wrote:

On 03/08/2018 05:24 PM, Li Zhijian wrote:

0Day robot tried to bisect the FBC, but it failed at last. But anyway
i want to let you know we had this issue.

Can you please bisect this, manually if necessary?  Let me know if you
need any help.



Try to bisect manually, but looks the 'git bisect' can not figure out the 
correct FBC.

First, the test has different behaviors at different commit. could you help to 
judge they are good or bad.
1) commit: 59c58ceb29d0f030eddb36a3a9dbadcc499786a6

XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x1f
XSAVE OS supported state mask: 0x1f
 BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
  BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0

[  OK  ] Reached target Timers.
[  OK  ] Started Permit User Sessions.
[FAILED] Failed to start OpenBSD Secure Shell server.executing unmaptest
mpx dig (  1) complete, SUCCESS (   0 /0)
unexpected trap 0! at 0x5663fbfa
si_addr (nil)
REG_ERR: 0
abort @ mpx-mini-test.c::450

 --

2) 74c8ce958dbf0b64f198becb5d8aa93afb967438
--
[3.423346] BUG: unable to handle kernel paging request at ff577060
[3.424283] IP: 0xf77cebe9
[3.424594] PGD 1c0a067
[3.424594] P4D 1c0a067
[3.424853] PUD 1c0c067
[3.425111] PMD 1c0d067
[3.425391] PTE 80002aa09161
[3.425741]
[3.426296] Oops: 0003 [#1] SMP
[3.426622] CPU: 0 PID: 359 Comm: mpx-mini-test_3 Not tainted 
4.11.0-rc2-00243-g74c8ce958dbf #37
[3.427508] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.11.0-20171110_100015-anatol 04/01/2014
[3.428533] task: 88003f46cb80 task.stack: c9738000
[3.429129] RIP: 0023:0xf77cebe9
[3.429456] RSP: 002b:ffb3df10 EFLAGS: 00010246
[3.429982] RAX: 0063 RBX: ffb3df10 RCX: f74bac98
[3.430696] RDX: f74ba700 RSI: f77f5000 RDI: 0001
[3.431442] RBP: ffb3e0c8 R08:  R09: 
[3.432153] R10:  R11:  R12: 
[3.432889] R13:  R14:  R15: 
[3.433723] FS:  () GS:88002aa0() 
knlGS:
[3.434540] CS:  0010 DS: 002b ES: 002b CR0: 80050033
[3.435130] CR2: ff577060 CR3: 3f52b000 CR4: 003406f0
[3.435928] DR0:  DR1:  DR2: 
[3.436653] DR3:  DR6: fffe0ff0 DR7: 0400
[3.437390] RIP: 0xf77cebe9 RSP: ffb3df10
[3.437869] CR2: ff577060
[3.438229] ---[ end trace dd63a5ceee1b0022 ]---
[3.438698] Kernel panic - not syncing: Fatal exception
[3.439316] Kernel Offset: disabled
[3.439680] ---[ end Kernel panic - not syncing: Fatal exception
qemu-system-x86_64: terminating on signal 2
--

3) 8f3e474f3cea7b2470218a6ed6da47ff02147dce

mpx dig (  2) complete, SUCCESS (7914 / 4986)
[2.733036] tsc: Refined TSC clocksource calibration: 3192.000 MHz
[2.733876] clocksource: tsc: mask: 0x max_cycles: 
0x2e02c4a121d, max_idle_ns: 440795236083 ns
mpx dig (  3) complete, SUCCESS (   11673 / 7372)
mpx dig (  4) complete, SUCCESS (   10703 / 6725)
mpx dig (  5) complete, SUCCESS (   0 /0)
mpx dig (  6) complete, SUCCESS ( 675 /  421)
mpx dig (  7) complete, SUCCESS ( 324 /  205)
[3.165773] input: ImExPS/2 Generic Explorer Mouse as 
/devices/platform/i8042/serio1/input/input3
mpx dig (  8) complete, SUCCESS (   0 /0)
mpx dig (  9) complete, SUCCESS (   0 /0)
mpx dig ( 10) complete, SUCCESS (   0 /0)
mpx dig ( 11) complete, SUCCESS (   0 /0)
mpx dig ( 12) complete, SUCCESS (   0 /0)
mpx dig ( 13) complete, SUCCESS (   0 /0)
mpx dig ( 14) complete, SUCCESS (   0 /0)
mpx dig ( 15) complete, SUCCESS (   0 /0)
mpx dig ( 16) complete, SUCCESS (   0 /0)
mpx dig ( 17) complete, SUCCESS (   0 /0)
iteration 1292 complete, OK so far
mpx dig ( 18) complete, SUCCESS (   0 /0)
mpx dig ( 19) complete, SUCCESS (   0 /0)
mpx dig ( 20) complete, SUCCESS (   0 /0)
mpx dig ( 21) complete, SUCCESS (   0 /0)
mpx dig ( 22) complete, SUCCESS (   0 /0)
mpx dig ( 23) complete, SUCCESS (   0 /0)
mpx dig ( 24) complete, SUCCESS (   0 /0)
mpx dig ( 25) complete, SUCCESS (   0 /0)
mpx dig ( 26) complete, SUCCESS (   0 /0)
mpx dig ( 27) complete, SUCCESS (   0 /0)
mpx dig ( 28) complete, SUCCESS (   0 /0)
mpx dig ( 29) complete, SUCCESS (   0 /0)
mpx dig ( 30) complete, SUCCESS (   0 /0)
mpx dig ( 31) complete, SUCCESS (   0 /0)
mpx dig ( 32) complete, SUCCESS (   0 /0)
mpx dig ( 33) complete, SUCCESS (   0 /0)
mpx dig ( 34) comp

Re: kernel_selftests.x86.mpx-mini-test_32.fail on skylake platform

2018-03-22 Thread Li Zhijian

Sorry to reply so late.

On 3/13/2018 1:34 AM, Dave Hansen wrote:

On 03/08/2018 05:24 PM, Li Zhijian wrote:

0Day robot tried to bisect the FBC, but it failed at last. But anyway
i want to let you know we had this issue.

Can you please bisect this, manually if necessary?  Let me know if you
need any help.



Try to bisect manually, but looks the 'git bisect' can not figure out the 
correct FBC.

First, the test has different behaviors at different commit. could you help to 
judge they are good or bad.
1) commit: 59c58ceb29d0f030eddb36a3a9dbadcc499786a6

XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x1f
XSAVE OS supported state mask: 0x1f
 BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
  BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0

[  OK  ] Reached target Timers.
[  OK  ] Started Permit User Sessions.
[FAILED] Failed to start OpenBSD Secure Shell server.executing unmaptest
mpx dig (  1) complete, SUCCESS (   0 /0)
unexpected trap 0! at 0x5663fbfa
si_addr (nil)
REG_ERR: 0
abort @ mpx-mini-test.c::450

 --

2) 74c8ce958dbf0b64f198becb5d8aa93afb967438
--
[3.423346] BUG: unable to handle kernel paging request at ff577060
[3.424283] IP: 0xf77cebe9
[3.424594] PGD 1c0a067
[3.424594] P4D 1c0a067
[3.424853] PUD 1c0c067
[3.425111] PMD 1c0d067
[3.425391] PTE 80002aa09161
[3.425741]
[3.426296] Oops: 0003 [#1] SMP
[3.426622] CPU: 0 PID: 359 Comm: mpx-mini-test_3 Not tainted 
4.11.0-rc2-00243-g74c8ce958dbf #37
[3.427508] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
1.11.0-20171110_100015-anatol 04/01/2014
[3.428533] task: 88003f46cb80 task.stack: c9738000
[3.429129] RIP: 0023:0xf77cebe9
[3.429456] RSP: 002b:ffb3df10 EFLAGS: 00010246
[3.429982] RAX: 0063 RBX: ffb3df10 RCX: f74bac98
[3.430696] RDX: f74ba700 RSI: f77f5000 RDI: 0001
[3.431442] RBP: ffb3e0c8 R08:  R09: 
[3.432153] R10:  R11:  R12: 
[3.432889] R13:  R14:  R15: 
[3.433723] FS:  () GS:88002aa0() 
knlGS:
[3.434540] CS:  0010 DS: 002b ES: 002b CR0: 80050033
[3.435130] CR2: ff577060 CR3: 3f52b000 CR4: 003406f0
[3.435928] DR0:  DR1:  DR2: 
[3.436653] DR3:  DR6: fffe0ff0 DR7: 0400
[3.437390] RIP: 0xf77cebe9 RSP: ffb3df10
[3.437869] CR2: ff577060
[3.438229] ---[ end trace dd63a5ceee1b0022 ]---
[3.438698] Kernel panic - not syncing: Fatal exception
[3.439316] Kernel Offset: disabled
[3.439680] ---[ end Kernel panic - not syncing: Fatal exception
qemu-system-x86_64: terminating on signal 2
--

3) 8f3e474f3cea7b2470218a6ed6da47ff02147dce

mpx dig (  2) complete, SUCCESS (7914 / 4986)
[2.733036] tsc: Refined TSC clocksource calibration: 3192.000 MHz
[2.733876] clocksource: tsc: mask: 0x max_cycles: 
0x2e02c4a121d, max_idle_ns: 440795236083 ns
mpx dig (  3) complete, SUCCESS (   11673 / 7372)
mpx dig (  4) complete, SUCCESS (   10703 / 6725)
mpx dig (  5) complete, SUCCESS (   0 /0)
mpx dig (  6) complete, SUCCESS ( 675 /  421)
mpx dig (  7) complete, SUCCESS ( 324 /  205)
[3.165773] input: ImExPS/2 Generic Explorer Mouse as 
/devices/platform/i8042/serio1/input/input3
mpx dig (  8) complete, SUCCESS (   0 /0)
mpx dig (  9) complete, SUCCESS (   0 /0)
mpx dig ( 10) complete, SUCCESS (   0 /0)
mpx dig ( 11) complete, SUCCESS (   0 /0)
mpx dig ( 12) complete, SUCCESS (   0 /0)
mpx dig ( 13) complete, SUCCESS (   0 /0)
mpx dig ( 14) complete, SUCCESS (   0 /0)
mpx dig ( 15) complete, SUCCESS (   0 /0)
mpx dig ( 16) complete, SUCCESS (   0 /0)
mpx dig ( 17) complete, SUCCESS (   0 /0)
iteration 1292 complete, OK so far
mpx dig ( 18) complete, SUCCESS (   0 /0)
mpx dig ( 19) complete, SUCCESS (   0 /0)
mpx dig ( 20) complete, SUCCESS (   0 /0)
mpx dig ( 21) complete, SUCCESS (   0 /0)
mpx dig ( 22) complete, SUCCESS (   0 /0)
mpx dig ( 23) complete, SUCCESS (   0 /0)
mpx dig ( 24) complete, SUCCESS (   0 /0)
mpx dig ( 25) complete, SUCCESS (   0 /0)
mpx dig ( 26) complete, SUCCESS (   0 /0)
mpx dig ( 27) complete, SUCCESS (   0 /0)
mpx dig ( 28) complete, SUCCESS (   0 /0)
mpx dig ( 29) complete, SUCCESS (   0 /0)
mpx dig ( 30) complete, SUCCESS (   0 /0)
mpx dig ( 31) complete, SUCCESS (   0 /0)
mpx dig ( 32) complete, SUCCESS (   0 /0)
mpx dig ( 33) complete, SUCCESS (   0 /0)
mpx dig ( 34) comp

kernel_selftests.x86.mpx-mini-test_32.fail on skylake platform

2018-03-08 Thread Li Zhijian

Hi all

0Day noticed that kernel_selftests.x86.mpx-mini-test_32.fail at recent upstream 
kernel
a. v4.11 Good
b. v4.12 and later: Bad

And the 64bit application kernel_selftests.x86.mpx-mini-test_64 is always good.

0Day robot tried to bisect the FBC, but it failed at last. But anyway i want to 
let you know we had this issue.

below is the testing log at v4.12
---
2018-03-02 23:12:08 make run_tests -C x86
make: Entering directory 
'/usr/src/linux-selftests-x86_64-rhel-7.2_mpx-6f7da290413ba713f0cdd9ff1a2a9bb129ef4f6c/tools/testing/selftests/x86'
#BR status == 2, missing bounds table,kernel should have handled!!
XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x2ff
XSAVE OS supported state mask: 0x2ff
 BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
  BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
executing unmaptest
mpx dig (  1) complete, SUCCESS (   0 /0)
selftests:  mpx-mini-test_32 [FAIL]
---

0Day Environment
OS: Debian 9
kernel: v4.12
model: Skylake
nr_cpu: 104
memory: 64G
brand: Intel(R) Xeon(R) Platinum 8170 CPU @ 2.10GHz

-
as a comparison, paste the log at v4.11 as following
XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x2ff
XSAVE OS supported state mask: 0x2ff
 BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
  BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
executing unmaptest
mpx dig (  1) complete, SUCCESS (   0 /0)
iteration 1 complete, OK so far
mpx dig (  2) complete, SUCCESS (8836 / 5554)
mpx dig (  3) complete, SUCCESS (2761 / 1760)
mpx dig (  4) complete, SUCCESS (4494 / 2828)
mpx dig (  5) complete, SUCCESS ( 531 /  337)
mpx dig (  6) complete, SUCCESS ( 145 /   92)
mpx dig (  7) complete, SUCCESS (   0 /0)
mpx dig (  8) complete, SUCCESS (   0 /0)
mpx dig (  9) complete, SUCCESS (   0 /0)
mpx dig ( 10) complete, SUCCESS (   0 /0)
mpx dig ( 11) complete, SUCCESS (   0 /0)
mpx dig ( 12) complete, SUCCESS (   0 /0)
mpx dig ( 13) complete, SUCCESS (   0 /0)
mpx dig ( 14) complete, SUCCESS (   0 /0)
mpx dig ( 15) complete, SUCCESS (   0 /0)
mpx dig ( 16) complete, SUCCESS (   0 /0)
iteration 1566 complete, OK so far
mpx dig ( 17) complete, SUCCESS (   0 /0)
mpx dig ( 18) complete, SUCCESS (   0 /0)
mpx dig ( 19) complete, SUCCESS (   0 /0)
mpx dig ( 20) complete, SUCCESS (   0 /0)
mpx dig ( 21) complete, SUCCESS (   0 /0)
mpx dig ( 22) complete, SUCCESS (   0 /0)
mpx dig ( 23) complete, SUCCESS (   0 /0)
mpx dig ( 24) complete, SUCCESS (   0 /0)
mpx dig ( 25) complete, SUCCESS (   0 /0)
mpx dig ( 26) complete, SUCCESS (   0 /0)
mpx dig ( 27) complete, SUCCESS (   0 /0)
mpx dig ( 28) complete, SUCCESS (   0 /0)
mpx dig ( 29) complete, SUCCESS (   0 /0)
mpx dig ( 30) complete, SUCCESS (   0 /0)
mpx dig ( 31) complete, SUCCESS (   0 /0)
mpx dig ( 32) complete, SUCCESS (   0 /0)
mpx dig ( 33) complete, SUCCESS (   0 /0)
mpx dig ( 34) complete, SUCCESS (   0 /0)
mpx dig ( 35) complete, SUCCESS (   0 /0)
mpx dig ( 36) complete, SUCCESS (   0 /0)
mpx dig ( 37) complete, SUCCESS (   0 /0)
mpx dig ( 38) complete, SUCCESS (   0 /0)
mpx dig ( 39) complete, SUCCESS (   0 /0)
mpx dig ( 40) complete, SUCCESS (   0 /0)
iteration 3325 complete, OK so far
done with malloc() fun
starting mpx bounds table test
iteration 4574 complete, OK so far
iteration 9157 complete, OK so far
done with mpx bounds table test
./mpx-mini-test_32 completed successfully
selftests: mpx-mini-test_32 [PASS]


Thanks



kernel_selftests.x86.mpx-mini-test_32.fail on skylake platform

2018-03-08 Thread Li Zhijian

Hi all

0Day noticed that kernel_selftests.x86.mpx-mini-test_32.fail at recent upstream 
kernel
a. v4.11 Good
b. v4.12 and later: Bad

And the 64bit application kernel_selftests.x86.mpx-mini-test_64 is always good.

0Day robot tried to bisect the FBC, but it failed at last. But anyway i want to 
let you know we had this issue.

below is the testing log at v4.12
---
2018-03-02 23:12:08 make run_tests -C x86
make: Entering directory 
'/usr/src/linux-selftests-x86_64-rhel-7.2_mpx-6f7da290413ba713f0cdd9ff1a2a9bb129ef4f6c/tools/testing/selftests/x86'
#BR status == 2, missing bounds table,kernel should have handled!!
XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x2ff
XSAVE OS supported state mask: 0x2ff
 BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
  BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
executing unmaptest
mpx dig (  1) complete, SUCCESS (   0 /0)
selftests:  mpx-mini-test_32 [FAIL]
---

0Day Environment
OS: Debian 9
kernel: v4.12
model: Skylake
nr_cpu: 104
memory: 64G
brand: Intel(R) Xeon(R) Platinum 8170 CPU @ 2.10GHz

-
as a comparison, paste the log at v4.11 as following
XSAVE is supported by HW & OS
XSAVE processor supported state mask: 0x2ff
XSAVE OS supported state mask: 0x2ff
 BNDREGS: size: 64 user: 1 supervisor: 0 aligned: 0
  BNDCSR: size: 64 user: 1 supervisor: 0 aligned: 0
executing unmaptest
mpx dig (  1) complete, SUCCESS (   0 /0)
iteration 1 complete, OK so far
mpx dig (  2) complete, SUCCESS (8836 / 5554)
mpx dig (  3) complete, SUCCESS (2761 / 1760)
mpx dig (  4) complete, SUCCESS (4494 / 2828)
mpx dig (  5) complete, SUCCESS ( 531 /  337)
mpx dig (  6) complete, SUCCESS ( 145 /   92)
mpx dig (  7) complete, SUCCESS (   0 /0)
mpx dig (  8) complete, SUCCESS (   0 /0)
mpx dig (  9) complete, SUCCESS (   0 /0)
mpx dig ( 10) complete, SUCCESS (   0 /0)
mpx dig ( 11) complete, SUCCESS (   0 /0)
mpx dig ( 12) complete, SUCCESS (   0 /0)
mpx dig ( 13) complete, SUCCESS (   0 /0)
mpx dig ( 14) complete, SUCCESS (   0 /0)
mpx dig ( 15) complete, SUCCESS (   0 /0)
mpx dig ( 16) complete, SUCCESS (   0 /0)
iteration 1566 complete, OK so far
mpx dig ( 17) complete, SUCCESS (   0 /0)
mpx dig ( 18) complete, SUCCESS (   0 /0)
mpx dig ( 19) complete, SUCCESS (   0 /0)
mpx dig ( 20) complete, SUCCESS (   0 /0)
mpx dig ( 21) complete, SUCCESS (   0 /0)
mpx dig ( 22) complete, SUCCESS (   0 /0)
mpx dig ( 23) complete, SUCCESS (   0 /0)
mpx dig ( 24) complete, SUCCESS (   0 /0)
mpx dig ( 25) complete, SUCCESS (   0 /0)
mpx dig ( 26) complete, SUCCESS (   0 /0)
mpx dig ( 27) complete, SUCCESS (   0 /0)
mpx dig ( 28) complete, SUCCESS (   0 /0)
mpx dig ( 29) complete, SUCCESS (   0 /0)
mpx dig ( 30) complete, SUCCESS (   0 /0)
mpx dig ( 31) complete, SUCCESS (   0 /0)
mpx dig ( 32) complete, SUCCESS (   0 /0)
mpx dig ( 33) complete, SUCCESS (   0 /0)
mpx dig ( 34) complete, SUCCESS (   0 /0)
mpx dig ( 35) complete, SUCCESS (   0 /0)
mpx dig ( 36) complete, SUCCESS (   0 /0)
mpx dig ( 37) complete, SUCCESS (   0 /0)
mpx dig ( 38) complete, SUCCESS (   0 /0)
mpx dig ( 39) complete, SUCCESS (   0 /0)
mpx dig ( 40) complete, SUCCESS (   0 /0)
iteration 3325 complete, OK so far
done with malloc() fun
starting mpx bounds table test
iteration 4574 complete, OK so far
iteration 9157 complete, OK so far
done with mpx bounds table test
./mpx-mini-test_32 completed successfully
selftests: mpx-mini-test_32 [PASS]


Thanks



[PATCH v2] selftests/vm/run_vmtests: adjust hugetlb size accroding to nr_cpus

2018-03-03 Thread Li Zhijian
Fix userfaultfd_hugetlb on hosts which have more than 64 cpus.

---
running userfaultfd_hugetlb
---
invalid MiB
Usage:  
[FAIL]

Via userfaultfd.c we can know, hugetlb_size needs to meet hugetlb_size >=
nr_cpus * hugepage_size.  hugepage_size is often 2M, so when host cpus >
64, it requires more than 128M.

Changes since v1:
  - update changelog/comments and variable name to make code more easier to
read/understand(stolen from Mike Kravetz)

Link: http://lkml.kernel.org/r/20180302024356.83359-1-zhijianx...@intel.com
Signed-off-by: Li Zhijian <zhijianx...@intel.com>
Cc: Shuah Khan <sh...@kernel.org>
Cc: SeongJae Park <sj38.p...@gmail.com>
Cc: Philippe Ombredanne <pombreda...@nexb.com>
Cc: Aneesh Kumar K.V <aneesh.ku...@linux.vnet.ibm.com>
Cc: Mike Kravetz <mike.krav...@oracle.com>
Signed-off-by: Andrew Morton <a...@linux-foundation.org>
---
 tools/testing/selftests/vm/run_vmtests | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/vm/run_vmtests 
b/tools/testing/selftests/vm/run_vmtests
index d2561895a021a..22d5646738302 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -2,25 +2,33 @@
 # SPDX-License-Identifier: GPL-2.0
 #please run as root
 
-#we need 256M, below is the size in kB
-needmem=262144
 mnt=./huge
 exitcode=0
 
-#get pagesize and freepages from /proc/meminfo
+#get huge pagesize and freepages from /proc/meminfo
 while read name size unit; do
if [ "$name" = "HugePages_Free:" ]; then
freepgs=$size
fi
if [ "$name" = "Hugepagesize:" ]; then
-   pgsize=$size
+   hpgsize_KB=$size
fi
 done < /proc/meminfo
 
+# Simple hugetlbfs tests have a hardcoded minimum requirement of
+# huge pages totaling 256MB (262144KB) in size.  The userfaultfd
+# hugetlb test requires a minimum of 2 * nr_cpus huge pages.  Take
+# both of these requirements into account and attempt to increase
+# number of huge pages available.
+nr_cpus=$(nproc)
+hpgsize_MB=$((hpgsize_KB / 1024))
+half_ufd_size_MB=$nr_cpus * hpgsize_MB + 127) / 128) * 128))
+needmem_KB=$((half_ufd_size_MB * 2 * 1024))
+
 #set proper nr_hugepages
-if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
+if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
-   needpgs=`expr $needmem / $pgsize`
+   needpgs=$((needmem_KB / hpgsize_KB))
tries=2
while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
lackpgs=$(( $needpgs - $freepgs ))
@@ -107,8 +115,9 @@ fi
 echo "---"
 echo "running userfaultfd_hugetlb"
 echo "---"
-# 256MB total huge pages == 128MB src and 128MB dst
-./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
+# Test requires source and destination huge pages.  Size of source
+# (half_ufd_size_MB) is passed as argument to test.
+./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file
 if [ $? -ne 0 ]; then
echo "[FAIL]"
exitcode=1
-- 
2.11.0



[PATCH v2] selftests/vm/run_vmtests: adjust hugetlb size accroding to nr_cpus

2018-03-03 Thread Li Zhijian
Fix userfaultfd_hugetlb on hosts which have more than 64 cpus.

---
running userfaultfd_hugetlb
---
invalid MiB
Usage:  
[FAIL]

Via userfaultfd.c we can know, hugetlb_size needs to meet hugetlb_size >=
nr_cpus * hugepage_size.  hugepage_size is often 2M, so when host cpus >
64, it requires more than 128M.

Changes since v1:
  - update changelog/comments and variable name to make code more easier to
read/understand(stolen from Mike Kravetz)

Link: http://lkml.kernel.org/r/20180302024356.83359-1-zhijianx...@intel.com
Signed-off-by: Li Zhijian 
Cc: Shuah Khan 
Cc: SeongJae Park 
Cc: Philippe Ombredanne 
Cc: Aneesh Kumar K.V 
Cc: Mike Kravetz 
Signed-off-by: Andrew Morton 
---
 tools/testing/selftests/vm/run_vmtests | 25 +
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/vm/run_vmtests 
b/tools/testing/selftests/vm/run_vmtests
index d2561895a021a..22d5646738302 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -2,25 +2,33 @@
 # SPDX-License-Identifier: GPL-2.0
 #please run as root
 
-#we need 256M, below is the size in kB
-needmem=262144
 mnt=./huge
 exitcode=0
 
-#get pagesize and freepages from /proc/meminfo
+#get huge pagesize and freepages from /proc/meminfo
 while read name size unit; do
if [ "$name" = "HugePages_Free:" ]; then
freepgs=$size
fi
if [ "$name" = "Hugepagesize:" ]; then
-   pgsize=$size
+   hpgsize_KB=$size
fi
 done < /proc/meminfo
 
+# Simple hugetlbfs tests have a hardcoded minimum requirement of
+# huge pages totaling 256MB (262144KB) in size.  The userfaultfd
+# hugetlb test requires a minimum of 2 * nr_cpus huge pages.  Take
+# both of these requirements into account and attempt to increase
+# number of huge pages available.
+nr_cpus=$(nproc)
+hpgsize_MB=$((hpgsize_KB / 1024))
+half_ufd_size_MB=$nr_cpus * hpgsize_MB + 127) / 128) * 128))
+needmem_KB=$((half_ufd_size_MB * 2 * 1024))
+
 #set proper nr_hugepages
-if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
+if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then
nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
-   needpgs=`expr $needmem / $pgsize`
+   needpgs=$((needmem_KB / hpgsize_KB))
tries=2
while [ $tries -gt 0 ] && [ $freepgs -lt $needpgs ]; do
lackpgs=$(( $needpgs - $freepgs ))
@@ -107,8 +115,9 @@ fi
 echo "---"
 echo "running userfaultfd_hugetlb"
 echo "---"
-# 256MB total huge pages == 128MB src and 128MB dst
-./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
+# Test requires source and destination huge pages.  Size of source
+# (half_ufd_size_MB) is passed as argument to test.
+./userfaultfd hugetlb $half_ufd_size_MB 32 $mnt/ufd_test_file
 if [ $? -ne 0 ]; then
echo "[FAIL]"
exitcode=1
-- 
2.11.0



[PATCH] selftests/vm/run_vmtests: adjust hugetlb size accroding to nr_cpus

2018-03-01 Thread Li Zhijian
this patch is to fix running userfaultfd_hugetlb failed on the host which has
more than 64 cpus
---
running userfaultfd_hugetlb
---
invalid MiB
Usage:  
[FAIL]

>From userfaultfd.c we can know, hugetlb_size need to meet hugetlb_size >= 
>nr_cpus * hugepage_size
hugepage_size is often 2M, so when host cpus > 64, it requires more than 128M.

Signed-off-by: Li Zhijian <zhijianx...@intel.com>
---
 tools/testing/selftests/vm/run_vmtests | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/vm/run_vmtests 
b/tools/testing/selftests/vm/run_vmtests
index d2561895a021a..c440fb972afe9 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -2,8 +2,6 @@
 # SPDX-License-Identifier: GPL-2.0
 #please run as root
 
-#we need 256M, below is the size in kB
-needmem=262144
 mnt=./huge
 exitcode=0
 
@@ -17,6 +15,13 @@ while read name size unit; do
fi
 done < /proc/meminfo
 
+nr_cpus=$(nproc)
+pgsize_MB=$((pgsize/1024))
+# rule: nr_cpus * pgsize_MB <= hugetlb_size(round to 128M for testing)
+hugetlb_size=$nr_cpus*pgsize_MB+127)/128)*128))
+# needmem depends on the nr_cpus, below is the size in kB
+needmem=$((hugetlb_size*2*1024))
+
 #set proper nr_hugepages
 if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
@@ -107,8 +112,8 @@ fi
 echo "---"
 echo "running userfaultfd_hugetlb"
 echo "---"
-# 256MB total huge pages == 128MB src and 128MB dst
-./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
+# 256MB total huge pages == 128MB src and 128MB dst when nr_cpus <= 64
+./userfaultfd hugetlb $hugetlb_size 32 $mnt/ufd_test_file
 if [ $? -ne 0 ]; then
echo "[FAIL]"
exitcode=1
-- 
2.11.0



[PATCH] selftests/vm/run_vmtests: adjust hugetlb size accroding to nr_cpus

2018-03-01 Thread Li Zhijian
this patch is to fix running userfaultfd_hugetlb failed on the host which has
more than 64 cpus
---
running userfaultfd_hugetlb
---
invalid MiB
Usage:  
[FAIL]

>From userfaultfd.c we can know, hugetlb_size need to meet hugetlb_size >= 
>nr_cpus * hugepage_size
hugepage_size is often 2M, so when host cpus > 64, it requires more than 128M.

Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/vm/run_vmtests | 13 +
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/vm/run_vmtests 
b/tools/testing/selftests/vm/run_vmtests
index d2561895a021a..c440fb972afe9 100755
--- a/tools/testing/selftests/vm/run_vmtests
+++ b/tools/testing/selftests/vm/run_vmtests
@@ -2,8 +2,6 @@
 # SPDX-License-Identifier: GPL-2.0
 #please run as root
 
-#we need 256M, below is the size in kB
-needmem=262144
 mnt=./huge
 exitcode=0
 
@@ -17,6 +15,13 @@ while read name size unit; do
fi
 done < /proc/meminfo
 
+nr_cpus=$(nproc)
+pgsize_MB=$((pgsize/1024))
+# rule: nr_cpus * pgsize_MB <= hugetlb_size(round to 128M for testing)
+hugetlb_size=$nr_cpus*pgsize_MB+127)/128)*128))
+# needmem depends on the nr_cpus, below is the size in kB
+needmem=$((hugetlb_size*2*1024))
+
 #set proper nr_hugepages
 if [ -n "$freepgs" ] && [ -n "$pgsize" ]; then
nr_hugepgs=`cat /proc/sys/vm/nr_hugepages`
@@ -107,8 +112,8 @@ fi
 echo "---"
 echo "running userfaultfd_hugetlb"
 echo "---"
-# 256MB total huge pages == 128MB src and 128MB dst
-./userfaultfd hugetlb 128 32 $mnt/ufd_test_file
+# 256MB total huge pages == 128MB src and 128MB dst when nr_cpus <= 64
+./userfaultfd hugetlb $hugetlb_size 32 $mnt/ufd_test_file
 if [ $? -ne 0 ]; then
echo "[FAIL]"
exitcode=1
-- 
2.11.0



[PATCH v2] selftests/bpf/test_maps: exit child process without error in ENOMEM case

2018-02-21 Thread Li Zhijian
From: Li Zhijian <zhijianx...@intel.com>

test_maps contains a series of stress tests, and previously it will break the
rest tests when it failed to alloc memory.
---
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=16 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
test_maps: test_maps.c:955: run_parallel: Assertion `status == 0' failed.
Aborted
not ok 1..3 selftests:  test_maps [FAIL]
---
after this patch, the rest tests will be continue when it occurs an ENOMEM 
failure

CC: Alexei Starovoitov <alexei.starovoi...@gmail.com>
CC: Philip Li <philip...@intel.com>
Suggested-by: Daniel Borkmann <dan...@iogearbox.net>
Signed-off-by: Li Zhijian <zhijianx...@intel.com>
---
 tools/testing/selftests/bpf/test_maps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_maps.c 
b/tools/testing/selftests/bpf/test_maps.c
index 436c4c7..9e03a4c 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -126,6 +126,8 @@ static void test_hashmap_sizes(int task, void *data)
fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j,
2, map_flags);
if (fd < 0) {
+   if (errno == ENOMEM)
+   return;
printf("Failed to create hashmap key=%d 
value=%d '%s'\n",
   i, j, strerror(errno));
exit(1);
-- 
2.7.4



[PATCH v2] selftests/bpf/test_maps: exit child process without error in ENOMEM case

2018-02-21 Thread Li Zhijian
From: Li Zhijian 

test_maps contains a series of stress tests, and previously it will break the
rest tests when it failed to alloc memory.
---
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=16 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
test_maps: test_maps.c:955: run_parallel: Assertion `status == 0' failed.
Aborted
not ok 1..3 selftests:  test_maps [FAIL]
---
after this patch, the rest tests will be continue when it occurs an ENOMEM 
failure

CC: Alexei Starovoitov 
CC: Philip Li 
Suggested-by: Daniel Borkmann 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/bpf/test_maps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_maps.c 
b/tools/testing/selftests/bpf/test_maps.c
index 436c4c7..9e03a4c 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -126,6 +126,8 @@ static void test_hashmap_sizes(int task, void *data)
fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j,
2, map_flags);
if (fd < 0) {
+   if (errno == ENOMEM)
+   return;
printf("Failed to create hashmap key=%d 
value=%d '%s'\n",
   i, j, strerror(errno));
exit(1);
-- 
2.7.4



[PATCH] selftests/bpf/test_maps: exit child process without error in ENOMEM case

2018-02-12 Thread Li Zhijian
From: Li Zhijian <zhijianx...@intel.com>

test_maps contains a series of stress tests, and previously it will break the
reset tests when it failed to alloc memory.
---
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=16 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
test_maps: test_maps.c:955: run_parallel: Assertion `status == 0' failed.
Aborted
not ok 1..3 selftests:  test_maps [FAIL]
---
after this patch, the rest tests will be continue when it occurs a ENOMEM 
failure

CC: Alexei Starovoitov <alexei.starovoi...@gmail.com>
CC: Philip Li <philip...@intel.com>
Suggest-by: Daniel Borkmann <dan...@iogearbox.net>
Signed-off-by: Li Zhijian <zhijianx...@intel.com>
---
 tools/testing/selftests/bpf/test_maps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_maps.c 
b/tools/testing/selftests/bpf/test_maps.c
index 436c4c7..9e03a4c 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -126,6 +126,8 @@ static void test_hashmap_sizes(int task, void *data)
fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j,
2, map_flags);
if (fd < 0) {
+   if (errno == ENOMEM)
+   return;
printf("Failed to create hashmap key=%d 
value=%d '%s'\n",
   i, j, strerror(errno));
exit(1);
-- 
2.7.4



[PATCH] selftests/bpf/test_maps: exit child process without error in ENOMEM case

2018-02-12 Thread Li Zhijian
From: Li Zhijian 

test_maps contains a series of stress tests, and previously it will break the
reset tests when it failed to alloc memory.
---
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=16 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
Failed to create hashmap key=8 value=262144 'Cannot allocate memory'
test_maps: test_maps.c:955: run_parallel: Assertion `status == 0' failed.
Aborted
not ok 1..3 selftests:  test_maps [FAIL]
---
after this patch, the rest tests will be continue when it occurs a ENOMEM 
failure

CC: Alexei Starovoitov 
CC: Philip Li 
Suggest-by: Daniel Borkmann 
Signed-off-by: Li Zhijian 
---
 tools/testing/selftests/bpf/test_maps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_maps.c 
b/tools/testing/selftests/bpf/test_maps.c
index 436c4c7..9e03a4c 100644
--- a/tools/testing/selftests/bpf/test_maps.c
+++ b/tools/testing/selftests/bpf/test_maps.c
@@ -126,6 +126,8 @@ static void test_hashmap_sizes(int task, void *data)
fd = bpf_create_map(BPF_MAP_TYPE_HASH, i, j,
2, map_flags);
if (fd < 0) {
+   if (errno == ENOMEM)
+   return;
printf("Failed to create hashmap key=%d 
value=%d '%s'\n",
   i, j, strerror(errno));
exit(1);
-- 
2.7.4



Re: [kselftests] compaction_test is blocked

2018-02-12 Thread Li Zhijian



On 2018年02月12日 11:26, Li Zhijian wrote:



On 2018年02月11日 13:44, Li Zhijian wrote:



On 02/10/2018 05:11 AM, Dan Rue wrote:

On Fri, Feb 09, 2018 at 03:53:59PM +0800, Li Zhijian wrote:

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours 
until i kill it.


Try to figure out where it is running, i added some log to this case.

the test log is like:
---
  [  111.750543] main: 248
  [  111.750544]-
  [ 111.750821] check_compaction: 98
  [  111.750822]-
  [  111.751102] check_compaction: 105
  [  111.751103]-
  [  111.751362] check_compaction: 111
  [  111.751363]-
  [  111.751621] check_compaction: 118
  [  111.751622]-
  [  111.751879] check_compaction: 123
  [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel 
will allocate

122    as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, 
__LINE__); <<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != 
(6*sizeof(char))) {    <<<< blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");

126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");

134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at 
the writing operation.


my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G

Hi Zhijian,

Please try this patch in mainline:

 4c1baad22390 kselftest: fix OOM in memory compaction test


Hi Dan

Thanks for your replies.

I run this case on v4.15, looks this patch is already merged to v4.15.
lizhijian@inn:~/linux$ git describe 4c1baad
v4.15-rc2-2-g4c1baad223906


My mistake, this path is not contained by v4.15 yet.
i will have a try.

Hi Dan,

I ran this case on this commit 4c1baad22390, this issue still occurs.

root@ivb44 ~# dmesg | tail -n 30
[  105.825870] main: 247

[  105.825994] main: 242

[  105.826130] main: 247

[  105.826250] main: 242

[  105.826394] main: 247

[  105.826506] main: 242

[  105.826617] main: 247

[  105.826728] main: 242

[  105.826840] main: 247

[  105.826950] main: 250

[  105.827272] check_compaction: 98

[  105.827589] check_compaction: 105

[  105.827849] check_compaction: 111

[  105.828152] check_compaction: 118

[  105.828451] check_compaction: 123


the runtime code is like
---
110
111 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
112 /* Start with the initial condition of 0 huge pages*/
113 if (write(fd, "0", sizeof(char)) != sizeof(char)) {
114 perror("Failed to write 0 to 
/proc/sys/vm/nr_hugepages\n");

115 goto close_fd;
116 }
117
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will 
allocate

122    as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
124 if (write(fd, "10", (6*sizeof(char))) != 
(6*sizeof(char))) {
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");

126 goto close_fd;
127 }
---

Thanks


Thanks





Thanks


Dan



NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian



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

the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html


.









Re: [kselftests] compaction_test is blocked

2018-02-12 Thread Li Zhijian



On 2018年02月12日 11:26, Li Zhijian wrote:



On 2018年02月11日 13:44, Li Zhijian wrote:



On 02/10/2018 05:11 AM, Dan Rue wrote:

On Fri, Feb 09, 2018 at 03:53:59PM +0800, Li Zhijian wrote:

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours 
until i kill it.


Try to figure out where it is running, i added some log to this case.

the test log is like:
---
  [  111.750543] main: 248
  [  111.750544]-
  [ 111.750821] check_compaction: 98
  [  111.750822]-
  [  111.751102] check_compaction: 105
  [  111.751103]-
  [  111.751362] check_compaction: 111
  [  111.751363]-
  [  111.751621] check_compaction: 118
  [  111.751622]-
  [  111.751879] check_compaction: 123
  [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel 
will allocate

122    as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, 
__LINE__); <<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != 
(6*sizeof(char))) {    <<<< blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");

126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");

134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at 
the writing operation.


my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G

Hi Zhijian,

Please try this patch in mainline:

 4c1baad22390 kselftest: fix OOM in memory compaction test


Hi Dan

Thanks for your replies.

I run this case on v4.15, looks this patch is already merged to v4.15.
lizhijian@inn:~/linux$ git describe 4c1baad
v4.15-rc2-2-g4c1baad223906


My mistake, this path is not contained by v4.15 yet.
i will have a try.

Hi Dan,

I ran this case on this commit 4c1baad22390, this issue still occurs.

root@ivb44 ~# dmesg | tail -n 30
[  105.825870] main: 247

[  105.825994] main: 242

[  105.826130] main: 247

[  105.826250] main: 242

[  105.826394] main: 247

[  105.826506] main: 242

[  105.826617] main: 247

[  105.826728] main: 242

[  105.826840] main: 247

[  105.826950] main: 250

[  105.827272] check_compaction: 98

[  105.827589] check_compaction: 105

[  105.827849] check_compaction: 111

[  105.828152] check_compaction: 118

[  105.828451] check_compaction: 123


the runtime code is like
---
110
111 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
112 /* Start with the initial condition of 0 huge pages*/
113 if (write(fd, "0", sizeof(char)) != sizeof(char)) {
114 perror("Failed to write 0 to 
/proc/sys/vm/nr_hugepages\n");

115 goto close_fd;
116 }
117
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will 
allocate

122    as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
124 if (write(fd, "10", (6*sizeof(char))) != 
(6*sizeof(char))) {
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");

126 goto close_fd;
127 }
---

Thanks


Thanks





Thanks


Dan



NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian



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

the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html


.









Re: [kselftests] compaction_test is blocked

2018-02-11 Thread Li Zhijian



On 2018年02月11日 13:44, Li Zhijian wrote:



On 02/10/2018 05:11 AM, Dan Rue wrote:

On Fri, Feb 09, 2018 at 03:53:59PM +0800, Li Zhijian wrote:

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours 
until i kill it.


Try to figure out where it is running, i added some log to this case.

the test log is like:
---
  [  111.750543] main: 248
  [  111.750544]-
  [ 111.750821] check_compaction: 98
  [  111.750822]-
  [  111.751102] check_compaction: 105
  [  111.751103]-
  [  111.751362] check_compaction: 111
  [  111.751363]-
  [  111.751621] check_compaction: 118
  [  111.751622]-
  [  111.751879] check_compaction: 123
  [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will 
allocate

122    as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__); 
<<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != 
(6*sizeof(char))) {    <<<< blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");

126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");

134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at 
the writing operation.


my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G

Hi Zhijian,

Please try this patch in mainline:

 4c1baad22390 kselftest: fix OOM in memory compaction test


Hi Dan

Thanks for your replies.

I run this case on v4.15, looks this patch is already merged to v4.15.
lizhijian@inn:~/linux$ git describe 4c1baad
v4.15-rc2-2-g4c1baad223906


My mistake, this path is not contained by v4.15 yet.
i will have a try.

Thanks





Thanks


Dan



NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian



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

the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html


.







Re: [kselftests] compaction_test is blocked

2018-02-11 Thread Li Zhijian



On 2018年02月11日 13:44, Li Zhijian wrote:



On 02/10/2018 05:11 AM, Dan Rue wrote:

On Fri, Feb 09, 2018 at 03:53:59PM +0800, Li Zhijian wrote:

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours 
until i kill it.


Try to figure out where it is running, i added some log to this case.

the test log is like:
---
  [  111.750543] main: 248
  [  111.750544]-
  [ 111.750821] check_compaction: 98
  [  111.750822]-
  [  111.751102] check_compaction: 105
  [  111.751103]-
  [  111.751362] check_compaction: 111
  [  111.751363]-
  [  111.751621] check_compaction: 118
  [  111.751622]-
  [  111.751879] check_compaction: 123
  [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will 
allocate

122    as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__); 
<<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != 
(6*sizeof(char))) {    <<<< blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");

126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");

134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at 
the writing operation.


my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G

Hi Zhijian,

Please try this patch in mainline:

 4c1baad22390 kselftest: fix OOM in memory compaction test


Hi Dan

Thanks for your replies.

I run this case on v4.15, looks this patch is already merged to v4.15.
lizhijian@inn:~/linux$ git describe 4c1baad
v4.15-rc2-2-g4c1baad223906


My mistake, this path is not contained by v4.15 yet.
i will have a try.

Thanks





Thanks


Dan



NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian



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

the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html


.







Re: [kselftests] compaction_test is blocked

2018-02-10 Thread Li Zhijian



On 02/10/2018 05:11 AM, Dan Rue wrote:

On Fri, Feb 09, 2018 at 03:53:59PM +0800, Li Zhijian wrote:

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours until i 
kill it.

Try to figure out where it is running, i added some log to this case.

the test log is like:
---
  [  111.750543] main: 248
  [  111.750544]-
  [ 111.750821] check_compaction: 98
  [  111.750822]-
  [  111.751102] check_compaction: 105
  [  111.751103]-
  [  111.751362] check_compaction: 111
  [  111.751363]-
  [  111.751621] check_compaction: 118
  [  111.751622]-
  [  111.751879] check_compaction: 123
  [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will allocate
122as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__); 
<<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != (6*sizeof(char))) {
<<<< blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");
126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");
134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at the writing 
operation.

my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G

Hi Zhijian,

Please try this patch in mainline:

 4c1baad22390 kselftest: fix OOM in memory compaction test


Hi Dan

Thanks for your replies.

I run this case on v4.15, looks this patch is already merged to v4.15.
lizhijian@inn:~/linux$ git describe 4c1baad
v4.15-rc2-2-g4c1baad223906

Thanks


Dan



NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian



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


.



--
Best regards.
Li Zhijian (8528)





Re: [kselftests] compaction_test is blocked

2018-02-10 Thread Li Zhijian



On 02/10/2018 05:11 AM, Dan Rue wrote:

On Fri, Feb 09, 2018 at 03:53:59PM +0800, Li Zhijian wrote:

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours until i 
kill it.

Try to figure out where it is running, i added some log to this case.

the test log is like:
---
  [  111.750543] main: 248
  [  111.750544]-
  [ 111.750821] check_compaction: 98
  [  111.750822]-
  [  111.751102] check_compaction: 105
  [  111.751103]-
  [  111.751362] check_compaction: 111
  [  111.751363]-
  [  111.751621] check_compaction: 118
  [  111.751622]-
  [  111.751879] check_compaction: 123
  [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will allocate
122as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__); 
<<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != (6*sizeof(char))) {
<<<< blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");
126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");
134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at the writing 
operation.

my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G

Hi Zhijian,

Please try this patch in mainline:

 4c1baad22390 kselftest: fix OOM in memory compaction test


Hi Dan

Thanks for your replies.

I run this case on v4.15, looks this patch is already merged to v4.15.
lizhijian@inn:~/linux$ git describe 4c1baad
v4.15-rc2-2-g4c1baad223906

Thanks


Dan



NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian



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


.



--
Best regards.
Li Zhijian (8528)





[kselftests] compaction_test is blocked

2018-02-08 Thread Li Zhijian

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours until i 
kill it.

Try to figure out where it is running, i added some log to this case.

the test log is like:
---
 [  111.750543] main: 248
 [  111.750544]-
 [ 111.750821] check_compaction: 98
 [  111.750822]-
 [  111.751102] check_compaction: 105
 [  111.751103]-
 [  111.751362] check_compaction: 111
 [  111.751363]-
 [  111.751621] check_compaction: 118
 [  111.751622]-
 [  111.751879] check_compaction: 123
 [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will allocate
122as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__); 
<<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != (6*sizeof(char))) {
 blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");
126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");
134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at the writing 
operation.

my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G


NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian





[kselftests] compaction_test is blocked

2018-02-08 Thread Li Zhijian

Hi

kselftests is integrated Intel 0Day project.
Sometimes we found compaction_test is blocked for more than 1 hours until i 
kill it.

Try to figure out where it is running, i added some log to this case.

the test log is like:
---
 [  111.750543] main: 248
 [  111.750544]-
 [ 111.750821] check_compaction: 98
 [  111.750822]-
 [  111.751102] check_compaction: 105
 [  111.751103]-
 [  111.751362] check_compaction: 111
 [  111.751363]-
 [  111.751621] check_compaction: 118
 [  111.751622]-
 [  111.751879] check_compaction: 123
 [  111.751880]-
---
118 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
119 lseek(fd, 0, SEEK_SET);
120
121 /* Request a large number of huge pages. The Kernel will allocate
122as much as it can */
123 fprintf(stderr, "%s: %d\n", __func__, __LINE__); 
<<< the last line we can catch.
124 if (write(fd, "10", (6*sizeof(char))) != (6*sizeof(char))) {
 blocking position
125 perror("Failed to write 10 to 
/proc/sys/vm/nr_hugepages\n");
126 goto close_fd;
127 }
128
129 lseek(fd, 0, SEEK_SET);
130
131 fprintf(stderr, "%s: %d\n", __func__, __LINE__);
132 if (read(fd, nr_hugepages, sizeof(nr_hugepages)) <= 0) {
133 perror("Failed to re-read from 
/proc/sys/vm/nr_hugepages\n");
134 goto close_fd;
135 }
---

According to above log and code, it most likely it is blocking at the writing 
operation.

my environment is like:
OS: debian
kernel: v4.15
model: Ivytown Ivy Bridge-EP
nr_cpu: 48
memory: 64G


NOTE: 0Day can reproduce this issue in 20% on 0Day.

Anybody can help have a look?

Thanks
Zhjian





[PATCH] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2017-12-27 Thread Li Zhijian
On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
 List symbols in [file(s)] (a.out by default).
 The options are:
...snip...
  -D, --dynamic  Display dynamic symbols instead of normal symbols
  --defined-only Display only defined symbols
  -e (ignored)
  -f, --format=FORMATUse the output format FORMAT.  FORMAT can be `bsd',
   `sysv' or `posix'.  The default is `bsd'
  -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter <tmri...@linux.vnet.ibm.com>
CC: Arnaldo Carvalho de Melo <a...@redhat.com>
Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
 tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 8b3da21..f939bd6 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
 . $(dirname $0)/lib/probe.sh
 
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
 
 trace_libc_inet_pton_backtrace() {
idx=0
-- 
2.7.4



[PATCH] perf test shell: Add -D to check dynamic symbols for ubuntu/debian

2017-12-27 Thread Li Zhijian
On Ubuntu and Debian, we can't find any symbol including "inet_pton" from 'nm 
-g'
root@vm-lkp-nex04-8G-5 ~# nm -g /lib/x86_64-linux-gnu/libc-2.25.so | grep 
inet_pton
nm: /lib/x86_64-linux-gnu/libc-2.25.so: no symbols

it looks libc.so has different symbol compositions at different distros

Usage: nm [option(s)] [file(s)]
 List symbols in [file(s)] (a.out by default).
 The options are:
...snip...
  -D, --dynamic  Display dynamic symbols instead of normal symbols
  --defined-only Display only defined symbols
  -e (ignored)
  -f, --format=FORMATUse the output format FORMAT.  FORMAT can be `bsd',
   `sysv' or `posix'.  The default is `bsd'
  -g, --extern-only  Display only external symbols

I tested both debian/ubuntu and RHEL, they work as expected

CC: Thomas Richter 
CC: Arnaldo Carvalho de Melo 
Signed-off-by: Li Zhijian 
---
 tools/perf/tests/shell/trace+probe_libc_inet_pton.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh 
b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
index 8b3da21..f939bd6 100755
--- a/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
+++ b/tools/perf/tests/shell/trace+probe_libc_inet_pton.sh
@@ -11,7 +11,7 @@
 . $(dirname $0)/lib/probe.sh
 
 libc=$(grep -w libc /proc/self/maps | head -1 | sed -r 
's/.*[[:space:]](\/.*)/\1/g')
-nm -g $libc 2>/dev/null | fgrep -q inet_pton || exit 254
+nm -gD $libc 2>/dev/null | fgrep -q inet_pton || exit 254
 
 trace_libc_inet_pton_backtrace() {
idx=0
-- 
2.7.4



Re: [PATCH v2] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-12-14 Thread Li Zhijian

ping


On 11/30/2017 09:36 AM, Li Zhijian wrote:

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
   CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
  from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
  from util/c++/clang-c.h:5,
  from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function 
‘atomic_read(const atomic_t*)()’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
  ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const 
atomic_t*)()’ is implicitly deleted because 
the default definition would be ill-formed:
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const 
member in ‘union atomic_read(const atomic_t*)::’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
   LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
  tools/include/linux/compiler.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..d6675c5 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
  
  #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  
+#ifdef __cplusplus

+#define READ_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define WRITE_ONCE(x, val) (*(volatile typeof(x) *)&(x)) = (val)
+#else
  #include 
  
  /*

@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
  #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
  
+#endif /* __cplusplus */
  
  #ifndef __fallthrough

  # define __fallthrough


--
Best regards.
Li Zhijian (8528)





Re: [PATCH v2] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-12-14 Thread Li Zhijian

ping


On 11/30/2017 09:36 AM, Li Zhijian wrote:

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
   CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
  from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
  from util/c++/clang-c.h:5,
  from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function 
‘atomic_read(const atomic_t*)()’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
  ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const 
atomic_t*)()’ is implicitly deleted because 
the default definition would be ill-formed:
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const 
member in ‘union atomic_read(const atomic_t*)::’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
   LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian 
---
  tools/include/linux/compiler.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..d6675c5 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
  
  #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  
+#ifdef __cplusplus

+#define READ_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define WRITE_ONCE(x, val) (*(volatile typeof(x) *)&(x)) = (val)
+#else
  #include 
  
  /*

@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
  #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
  
+#endif /* __cplusplus */
  
  #ifndef __fallthrough

  # define __fallthrough


--
Best regards.
Li Zhijian (8528)





[PATCH v2] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-29 Thread Li Zhijian
since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
  CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
 from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
 from util/c++/clang-c.h:5,
 from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted 
function ‘atomic_read(const atomic_t*)()’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
 ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: 
‘atomic_read(const atomic_t*)()’ is 
implicitly deleted because the default definition would be ill-formed:
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized 
const member in ‘union atomic_read(const atomic_t*)::’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
  LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
 tools/include/linux/compiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..d6675c5 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#ifdef __cplusplus
+#define READ_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define WRITE_ONCE(x, val) (*(volatile typeof(x) *)&(x)) = (val)
+#else
 #include 
 
 /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#endif /* __cplusplus */
 
 #ifndef __fallthrough
 # define __fallthrough
-- 
2.7.4



[PATCH v2] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-29 Thread Li Zhijian
since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
  CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
 from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
 from util/c++/clang-c.h:5,
 from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted 
function ‘atomic_read(const atomic_t*)()’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
 ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: 
‘atomic_read(const atomic_t*)()’ is 
implicitly deleted because the default definition would be ill-formed:
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized 
const member in ‘union atomic_read(const atomic_t*)::’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
  LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian 
---
 tools/include/linux/compiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..d6675c5 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#ifdef __cplusplus
+#define READ_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define WRITE_ONCE(x, val) (*(volatile typeof(x) *)&(x)) = (val)
+#else
 #include 
 
 /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#endif /* __cplusplus */
 
 #ifndef __fallthrough
 # define __fallthrough
-- 
2.7.4



Re: [PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-28 Thread Li Zhijian


On 11/28/2017 07:30 PM, Mark Rutland wrote:

Hi,

[Fixed acme's address and added more Ccs]

thanks




On Tue, Nov 28, 2017 at 02:13:42PM +0800, Li Zhijian wrote:

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors

Sorry about this.

With llvm-config and libclang from the LLVM 5.0.0 release, I can
reproduce this.


--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
   CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
  from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
  from util/c++/clang-c.h:5,
  from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function 
‘atomic_read(const atomic_t*)()’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
  ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const 
atomic_t*)()’ is implicitly deleted because 
the default definition would be ill-formed:
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const 
member in ‘union atomic_read(const atomic_t*)::’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
   LD   tests/perf-in.o

So IIUC, g++ doesn't like the union aliasing trick that we use here, and
doesn't believe that __val has been initialised.

I haven't found a way around that yet. Ideally we'd just have a
non-const temporary (and a __builtin_memcpy) rather than a union, but I
can't find a way to strip const from typeof() prior to c++11.


...
----------

Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
  tools/include/linux/compiler.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
  
  #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  
+#ifdef __cplusplus

+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
  #include 

This is somewhat unfortunate, since we want to get rid of ACCESS_ONCE().


Got it




I'll see if I can come up with something to make the existing
{READ,WRITE}_ONCE() work, so that we can avoid issues with non-scalar
types.


That's great if we can bring up the existing code.


Thanks
Zhijian



Otherwise, could we please make these:

#define READ_ONCE(x)(*(volatile typeof(x) *)&(x))
#define WRITE_ONCE(x)   (*(volatile typeof(x) *)&(x)) = (val)

Thanks,
Mark.


  /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
  #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
  
+#endif /* __cplusplus */
  
  #ifndef __fallthrough

  # define __fallthrough
--
2.7.4









Re: [PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-28 Thread Li Zhijian


On 11/28/2017 07:30 PM, Mark Rutland wrote:

Hi,

[Fixed acme's address and added more Ccs]

thanks




On Tue, Nov 28, 2017 at 02:13:42PM +0800, Li Zhijian wrote:

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors

Sorry about this.

With llvm-config and libclang from the LLVM 5.0.0 release, I can
reproduce this.


--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
   CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
  from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
  from util/c++/clang-c.h:5,
  from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function 
‘atomic_read(const atomic_t*)()’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
  ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const 
atomic_t*)()’ is implicitly deleted because 
the default definition would be ill-formed:
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const 
member in ‘union atomic_read(const atomic_t*)::’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
   LD   tests/perf-in.o

So IIUC, g++ doesn't like the union aliasing trick that we use here, and
doesn't believe that __val has been initialised.

I haven't found a way around that yet. Ideally we'd just have a
non-const temporary (and a __builtin_memcpy) rather than a union, but I
can't find a way to strip const from typeof() prior to c++11.


...
----------

Signed-off-by: Li Zhijian 
---
  tools/include/linux/compiler.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
  
  #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  
+#ifdef __cplusplus

+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
  #include 

This is somewhat unfortunate, since we want to get rid of ACCESS_ONCE().


Got it




I'll see if I can come up with something to make the existing
{READ,WRITE}_ONCE() work, so that we can avoid issues with non-scalar
types.


That's great if we can bring up the existing code.


Thanks
Zhijian



Otherwise, could we please make these:

#define READ_ONCE(x)(*(volatile typeof(x) *)&(x))
#define WRITE_ONCE(x)   (*(volatile typeof(x) *)&(x)) = (val)

Thanks,
Mark.


  /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
  #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
  
+#endif /* __cplusplus */
  
  #ifndef __fallthrough

  # define __fallthrough
--
2.7.4









Re: [PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-27 Thread Li Zhijian

add Arnaldo Carvalho de Melo <a...@redhat.com>


On 11/28/2017 02:13 PM, Li Zhijian wrote:

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
   CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
  from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
  from util/c++/clang-c.h:5,
  from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function 
‘atomic_read(const atomic_t*)()’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
  ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const 
atomic_t*)()’ is implicitly deleted because 
the default definition would be ill-formed:
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const 
member in ‘union atomic_read(const atomic_t*)::’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
   LD   tests/perf-in.o
...
------

Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
  tools/include/linux/compiler.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
  
  #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  
+#ifdef __cplusplus

+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
  #include 
  
  /*

@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
  #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
  
+#endif /* __cplusplus */
  
  #ifndef __fallthrough

  # define __fallthrough






Re: [PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-27 Thread Li Zhijian

add Arnaldo Carvalho de Melo 


On 11/28/2017 02:13 PM, Li Zhijian wrote:

since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
   CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
  from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
  from util/c++/clang-c.h:5,
  from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted function 
‘atomic_read(const atomic_t*)()’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
  ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: ‘atomic_read(const 
atomic_t*)()’ is implicitly deleted because 
the default definition would be ill-formed:
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized const 
member in ‘union atomic_read(const atomic_t*)::’
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
   ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
   return READ_ONCE((v)->counter);
  ^
   LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian 
---
  tools/include/linux/compiler.h | 5 +
  1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
  
  #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  
+#ifdef __cplusplus

+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
  #include 
  
  /*

@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
  #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
  
+#endif /* __cplusplus */
  
  #ifndef __fallthrough

  # define __fallthrough






[PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-27 Thread Li Zhijian
since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
  CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
 from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
 from util/c++/clang-c.h:5,
 from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted 
function ‘atomic_read(const atomic_t*)()’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
 ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: 
‘atomic_read(const atomic_t*)()’ is 
implicitly deleted because the default definition would be ill-formed:
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized 
const member in ‘union atomic_read(const atomic_t*)::’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
  LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian <lizhij...@cn.fujitsu.com>
---
 tools/include/linux/compiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#ifdef __cplusplus
+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
 #include 
 
 /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#endif /* __cplusplus */
 
 #ifndef __fallthrough
 # define __fallthrough
-- 
2.7.4



[PATCH] tools include: define READ_ONCE/WRITE_ONCE for C++

2017-11-27 Thread Li Zhijian
since 6aa7de0, we failed to build perf with C++(clang)
to fix the following compile errors
--
lizhijian@haswell-OptiPlex-9020:~/lkp/linux/tools/perf$ make 
LLVM_CONFIG=/usr/bin/llvm-config-3.9 LIBCLANGLLVM=1
...
  CC   util/probe-finder.o
In file included from /home/lizj/linux/tools/perf/util/util.h:13:0,
 from /home/lizj/linux/tools/perf/util/util-cxx.h:20,
 from util/c++/clang-c.h:5,
 from util/c++/clang-test.cpp:2:
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h: In 
function ‘int atomic_read(const atomic_t*)’:
/home/lizj/linux/tools/include/linux/compiler.h:157:45: error: use of deleted 
function ‘atomic_read(const atomic_t*)()’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
 ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: note: 
‘atomic_read(const atomic_t*)()’ is 
implicitly deleted because the default definition would be ill-formed:
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:11: error: uninitialized 
const member in ‘union atomic_read(const atomic_t*)::’
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
/home/lizj/linux/tools/include/linux/compiler.h:157:23: note: ‘const int 
atomic_read(const atomic_t*)__val’ should be initialized
  ({ union { typeof(x) __val; char __c[1]; } __u; __read_once_size(&(x), 
__u.__c, sizeof(x)); __u.__val; })
   ^
/home/lizj/linux/tools/include/asm/../../arch/x86/include/asm/atomic.h:28:9: 
note: in expansion of macro ‘READ_ONCE’
  return READ_ONCE((v)->counter);
 ^
  LD   tests/perf-in.o
...
----------

Signed-off-by: Li Zhijian 
---
 tools/include/linux/compiler.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/tools/include/linux/compiler.h b/tools/include/linux/compiler.h
index 07fd03c..e4c8a0d 100644
--- a/tools/include/linux/compiler.h
+++ b/tools/include/linux/compiler.h
@@ -86,6 +86,10 @@
 
 #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
 
+#ifdef __cplusplus
+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
+#else
 #include 
 
 /*
@@ -160,6 +164,7 @@ static __always_inline void __write_once_size(volatile void 
*p, void *res, int s
 #define WRITE_ONCE(x, val) \
({ union { typeof(x) __val; char __c[1]; } __u = { .__val = (val) }; 
__write_once_size(&(x), __u.__c, sizeof(x)); __u.__val; })
 
+#endif /* __cplusplus */
 
 #ifndef __fallthrough
 # define __fallthrough
-- 
2.7.4



Re: [lkp-robot] [perf/x86] a5df70c354: perf-sanity-tests.Parse_event_definition_strings.fail

2017-10-29 Thread Li Zhijian
---


Thanks
Zhijian


On 10/28/2017 4:44 AM, Andi Kleen wrote:

On Fri, Oct 27, 2017 at 04:11:09PM +0800, Li Zhijian wrote:

+ members of perf test

ping

add more results on different platforms
haswell: FAIL(OK at v4.13)

Don't have a system, but can you please post the output of

perf test -F 6 -v

on the Haswell?

-Andi




Re: [lkp-robot] [perf/x86] a5df70c354: perf-sanity-tests.Parse_event_definition_strings.fail

2017-10-29 Thread Li Zhijian
---


Thanks
Zhijian


On 10/28/2017 4:44 AM, Andi Kleen wrote:

On Fri, Oct 27, 2017 at 04:11:09PM +0800, Li Zhijian wrote:

+ members of perf test

ping

add more results on different platforms
haswell: FAIL(OK at v4.13)

Don't have a system, but can you please post the output of

perf test -F 6 -v

on the Haswell?

-Andi




Re: perf test vfs_getname failed

2017-10-23 Thread Li Zhijian

Those cases can be passed on fedora-26 with the same kernel(and configuration) 
with rhel7.1
[root@localhost perf]# ./perf test vfs_getname
60: Add vfs_getname probe to get syscall args filenames   : Ok
61: Use vfs_getname probe to get syscall args filenames   : Ok
62: Check open filename arg using perf trace + vfs_getname: Ok

totally, i tested at 3 distro
1. fedora-26: OK
2. ubuntu 16.04: FAIL
3. rhel7.1 beta: FAIL

Does it means that those cases are related to special distro(require special 
middle wares) ?


Thanks


On 10/19/2017 4:31 PM, Li Zhijian wrote:

Hi Arnaldo

i encounter some problem when running perf test, the details arelike 
below:


-

[lizj@rhel71 perf]$ sudo ./perf test vfs_getname -v
61: Add vfs_getname probe to get syscall args filenames   :
--- start ---
test child forked, pid 5958
Failed to find 'result' in this function.
  Error: Failed to add events.
test child finished with -1
 end 
Add vfs_getname probe to get syscall args filenames: FAILED!
62: Use vfs_getname probe to get syscall args filenames   :
--- start ---
test child forked, pid 5979
Failed to find 'result' in this function.
  Error: Failed to add events.
test child finished with -1
 end 
Use vfs_getname probe to get syscall args filenames: FAILED!
63: Check open filename arg using perf trace + vfs_getname:
--- start ---
test child forked, pid 6001
Failed to find 'result' in this function.
  Error: Failed to add events.
test child finished with -1
 end 
Check open filename arg using perf trace + vfs_getname: FAILED!
-

my environment:
1. perf features
the enabled features are:
-

Auto-detecting system features:
... dwarf: [ on  ]
...    dwarf_getlocations: [ on  ]
... glibc: [ on  ]
...  gtk2: [ on  ]
...  libaudit: [ on  ]
...    libbfd: [ on  ]
...    libelf: [ on  ]
...   libnuma: [ on  ]
...    numa_num_possible_cpus: [ on  ]
...   libperl: [ on  ]
... libpython: [ on  ]
...  libslang: [ OFF ]
... libcrypto: [ on  ]
... libunwind: [ on  ]
...    libdw-dwarf-unwind: [ on  ]
...  zlib: [ on  ]
...  lzma: [ on  ]
... get_cpuid: [ on  ]
...   bpf: [ on  ]
-
2. host
[lizj@rhel71 perf]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 Beta (Maipo)

3. kernel
[lizj@rhel71 perf]$ uname -a
Linux rhel71 4.14.0-rc1+ #2 SMP Wed Oct 18 23:49:30 EDT 2017 x86_64 
x86_64 x86_64 GNU/Linux


if i miss something, fell free to let me know :)

Thanks

Zhijian






Re: perf test vfs_getname failed

2017-10-23 Thread Li Zhijian

Those cases can be passed on fedora-26 with the same kernel(and configuration) 
with rhel7.1
[root@localhost perf]# ./perf test vfs_getname
60: Add vfs_getname probe to get syscall args filenames   : Ok
61: Use vfs_getname probe to get syscall args filenames   : Ok
62: Check open filename arg using perf trace + vfs_getname: Ok

totally, i tested at 3 distro
1. fedora-26: OK
2. ubuntu 16.04: FAIL
3. rhel7.1 beta: FAIL

Does it means that those cases are related to special distro(require special 
middle wares) ?


Thanks


On 10/19/2017 4:31 PM, Li Zhijian wrote:

Hi Arnaldo

i encounter some problem when running perf test, the details arelike 
below:


-

[lizj@rhel71 perf]$ sudo ./perf test vfs_getname -v
61: Add vfs_getname probe to get syscall args filenames   :
--- start ---
test child forked, pid 5958
Failed to find 'result' in this function.
  Error: Failed to add events.
test child finished with -1
 end 
Add vfs_getname probe to get syscall args filenames: FAILED!
62: Use vfs_getname probe to get syscall args filenames   :
--- start ---
test child forked, pid 5979
Failed to find 'result' in this function.
  Error: Failed to add events.
test child finished with -1
 end 
Use vfs_getname probe to get syscall args filenames: FAILED!
63: Check open filename arg using perf trace + vfs_getname:
--- start ---
test child forked, pid 6001
Failed to find 'result' in this function.
  Error: Failed to add events.
test child finished with -1
 end 
Check open filename arg using perf trace + vfs_getname: FAILED!
-

my environment:
1. perf features
the enabled features are:
-

Auto-detecting system features:
... dwarf: [ on  ]
...    dwarf_getlocations: [ on  ]
... glibc: [ on  ]
...  gtk2: [ on  ]
...  libaudit: [ on  ]
...    libbfd: [ on  ]
...    libelf: [ on  ]
...   libnuma: [ on  ]
...    numa_num_possible_cpus: [ on  ]
...   libperl: [ on  ]
... libpython: [ on  ]
...  libslang: [ OFF ]
... libcrypto: [ on  ]
... libunwind: [ on  ]
...    libdw-dwarf-unwind: [ on  ]
...  zlib: [ on  ]
...  lzma: [ on  ]
... get_cpuid: [ on  ]
...   bpf: [ on  ]
-
2. host
[lizj@rhel71 perf]$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.1 Beta (Maipo)

3. kernel
[lizj@rhel71 perf]$ uname -a
Linux rhel71 4.14.0-rc1+ #2 SMP Wed Oct 18 23:49:30 EDT 2017 x86_64 
x86_64 x86_64 GNU/Linux


if i miss something, fell free to let me know :)

Thanks

Zhijian






  1   2   >