[PATCH] net: spi: fix a potential NULL pointer dereference
In case alloc_workqueue fails to allocate the work queue and returns NULL, the fix releases the resources and returns -ENOMEM. Signed-off-by: Kangjie Lu --- drivers/net/can/spi/mcp251x.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c index e90817608645..2737b9a20dfe 100644 --- a/drivers/net/can/spi/mcp251x.c +++ b/drivers/net/can/spi/mcp251x.c @@ -962,6 +962,14 @@ static int mcp251x_open(struct net_device *net) priv->wq = alloc_workqueue("mcp251x_wq", WQ_FREEZABLE | WQ_MEM_RECLAIM, 0); + if (unlikely(!priv->wq)) { + dev_err(>dev, "failed to allocate work queue\n"); + mcp251x_power_enable(priv->transceiver, 0); + close_candev(net); + ret = -ENOMEM; + goto open_unlock; + } + INIT_WORK(>tx_work, mcp251x_tx_work_handler); INIT_WORK(>restart_work, mcp251x_restart_work_handler); -- 2.17.1
Re: [PATCH] staging: erofs: add a new line after variable declaration
Hi Julio, On 2019/3/10 1:08, Julio Bianco wrote: > Add a new line after variable declaration > > Signed-off-by: Julio Bianco There is the only place in erofs for this issue? Could you check and please fix them all if you have some time? Thanks, Gao Xiang > --- > drivers/staging/erofs/inode.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/staging/erofs/inode.c b/drivers/staging/erofs/inode.c > index 924b8dfc7a8f..1cf1afe2d73a 100644 > --- a/drivers/staging/erofs/inode.c > +++ b/drivers/staging/erofs/inode.c > @@ -270,6 +270,7 @@ struct inode *erofs_iget(struct super_block *sb, > if (inode->i_state & I_NEW) { > int err; > struct erofs_vnode *vi = EROFS_V(inode); > + > vi->nid = nid; > > err = fill_inode(inode, isdir);
[PATCH] mmc_spi: add a status check for spi_sync_locked
In case spi_sync_locked fails, the fix reports the error and returns the error code upstream. Signed-off-by: Kangjie Lu --- drivers/mmc/host/mmc_spi.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c index 1b1498805972..32fea585262b 100644 --- a/drivers/mmc/host/mmc_spi.c +++ b/drivers/mmc/host/mmc_spi.c @@ -819,6 +819,10 @@ mmc_spi_readblock(struct mmc_spi_host *host, struct spi_transfer *t, } status = spi_sync_locked(spi, >m); + if (status < 0) { + dev_dbg(>dev, "read error %02x (%d)\n", status, status); + return status; + } if (host->dma_dev) { dma_sync_single_for_cpu(host->dma_dev, -- 2.17.1
[PATCH 8/8] aio: move sanity checks and request allocation to io_submit_one()
From: Al Viro makes for somewhat cleaner control flow in __io_submit_one() Signed-off-by: Al Viro --- fs/aio.c | 119 --- 1 file changed, 53 insertions(+), 66 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 66ca52c57cca..2d1db52b1268 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1780,35 +1780,12 @@ static int aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) } static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, - struct iocb __user *user_iocb, bool compat) + struct iocb __user *user_iocb, struct aio_kiocb *req, + bool compat) { - struct aio_kiocb *req; - int ret; - - /* enforce forwards compatibility on users */ - if (unlikely(iocb->aio_reserved2)) { - pr_debug("EINVAL: reserve field set\n"); - return -EINVAL; - } - - /* prevent overflows */ - if (unlikely( - (iocb->aio_buf != (unsigned long)iocb->aio_buf) || - (iocb->aio_nbytes != (size_t)iocb->aio_nbytes) || - ((ssize_t)iocb->aio_nbytes < 0) - )) { - pr_debug("EINVAL: overflow check\n"); - return -EINVAL; - } - - req = aio_get_req(ctx); - if (unlikely(!req)) - return -EAGAIN; - req->ki_filp = fget(iocb->aio_fildes); - ret = -EBADF; if (unlikely(!req->ki_filp)) - goto out_put_req; + return -EBADF; if (iocb->aio_flags & IOCB_FLAG_RESFD) { struct eventfd_ctx *eventfd; @@ -1819,17 +1796,15 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, * event using the eventfd_signal() function. */ eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd); - if (IS_ERR(eventfd)) { - ret = PTR_ERR(eventfd); - goto out_put_req; - } + if (IS_ERR(eventfd)) + return PTR_ERR(req->ki_eventfd); + req->ki_eventfd = eventfd; } - ret = put_user(KIOCB_KEY, _iocb->aio_key); - if (unlikely(ret)) { + if (unlikely(put_user(KIOCB_KEY, _iocb->aio_key))) { pr_debug("EFAULT: aio_key\n"); - goto out_put_req; + return -EFAULT; } req->ki_res.obj = (u64)(unsigned long)user_iocb; @@ -1839,58 +1814,70 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, switch (iocb->aio_lio_opcode) { case IOCB_CMD_PREAD: - ret = aio_read(>rw, iocb, false, compat); - break; + return aio_read(>rw, iocb, false, compat); case IOCB_CMD_PWRITE: - ret = aio_write(>rw, iocb, false, compat); - break; + return aio_write(>rw, iocb, false, compat); case IOCB_CMD_PREADV: - ret = aio_read(>rw, iocb, true, compat); - break; + return aio_read(>rw, iocb, true, compat); case IOCB_CMD_PWRITEV: - ret = aio_write(>rw, iocb, true, compat); - break; + return aio_write(>rw, iocb, true, compat); case IOCB_CMD_FSYNC: - ret = aio_fsync(>fsync, iocb, false); - break; + return aio_fsync(>fsync, iocb, false); case IOCB_CMD_FDSYNC: - ret = aio_fsync(>fsync, iocb, true); - break; + return aio_fsync(>fsync, iocb, true); case IOCB_CMD_POLL: - ret = aio_poll(req, iocb); - break; + return aio_poll(req, iocb); default: pr_debug("invalid aio operation %d\n", iocb->aio_lio_opcode); - ret = -EINVAL; - break; + return -EINVAL; } - - /* Done with the synchronous reference */ - iocb_put(req); - - /* -* If ret is 0, we'd either done aio_complete() ourselves or have -* arranged for that to be done asynchronously. Anything non-zero -* means that we need to destroy req ourselves. -*/ - if (!ret) - return 0; - -out_put_req: - iocb_destroy(req); - put_reqs_available(ctx, 1); - return ret; } static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb, bool compat) { + struct aio_kiocb *req; struct iocb iocb; + int err; if (unlikely(copy_from_user(, user_iocb, sizeof(iocb return -EFAULT; - return __io_submit_one(ctx, , user_iocb, compat); + /* enforce forwards compatibility on users */ + if (unlikely(iocb.aio_reserved2)) { + pr_debug("EINVAL: reserve field set\n"); + return -EINVAL; + } + +
[PATCH 6/8] move dropping ->ki_eventfd into iocb_destroy()
From: Al Viro Signed-off-by: Al Viro --- fs/aio.c | 17 - 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index f9e8f1edfe36..595c19965a8b 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1071,6 +1071,8 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id) static inline void iocb_destroy(struct aio_kiocb *iocb) { + if (iocb->ki_eventfd) + eventfd_ctx_put(iocb->ki_eventfd); if (iocb->ki_filp) fput(iocb->ki_filp); percpu_ref_put(>ki_ctx->reqs); @@ -1138,10 +1140,8 @@ static void aio_complete(struct aio_kiocb *iocb) * eventfd. The eventfd_signal() function is safe to be called * from IRQ context. */ - if (iocb->ki_eventfd) { + if (iocb->ki_eventfd) eventfd_signal(iocb->ki_eventfd, 1); - eventfd_ctx_put(iocb->ki_eventfd); - } /* * We have to order our ring_info tail store above and test @@ -1810,18 +1810,19 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, goto out_put_req; if (iocb->aio_flags & IOCB_FLAG_RESFD) { + struct eventfd_ctx *eventfd; /* * If the IOCB_FLAG_RESFD flag of aio_flags is set, get an * instance of the file* now. The file descriptor must be * an eventfd() fd, and will be signaled for each completed * event using the eventfd_signal() function. */ - req->ki_eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd); - if (IS_ERR(req->ki_eventfd)) { - ret = PTR_ERR(req->ki_eventfd); - req->ki_eventfd = NULL; + eventfd = eventfd_ctx_fdget((int) iocb->aio_resfd); + if (IS_ERR(eventfd)) { + ret = PTR_ERR(eventfd); goto out_put_req; } + req->ki_eventfd = eventfd; } ret = put_user(KIOCB_KEY, _iocb->aio_key); @@ -1875,8 +1876,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, return 0; out_put_req: - if (req->ki_eventfd) - eventfd_ctx_put(req->ki_eventfd); iocb_destroy(req); out_put_reqs_available: put_reqs_available(ctx, 1); -- 2.11.0
[PATCH 7/8] deal with get_reqs_available() in aio_get_req() itself
From: Al Viro simplifies the caller Signed-off-by: Al Viro --- fs/aio.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 595c19965a8b..66ca52c57cca 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1033,6 +1033,11 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) if (unlikely(!req)) return NULL; + if (unlikely(!get_reqs_available(ctx))) { + kfree(req); + return NULL; + } + percpu_ref_get(>reqs); req->ki_ctx = ctx; INIT_LIST_HEAD(>ki_list); @@ -1796,13 +1801,9 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, return -EINVAL; } - if (!get_reqs_available(ctx)) - return -EAGAIN; - - ret = -EAGAIN; req = aio_get_req(ctx); if (unlikely(!req)) - goto out_put_reqs_available; + return -EAGAIN; req->ki_filp = fget(iocb->aio_fildes); ret = -EBADF; @@ -1877,7 +1878,6 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, out_put_req: iocb_destroy(req); -out_put_reqs_available: put_reqs_available(ctx, 1); return ret; } -- 2.11.0
[PATCH 4/8] Fix aio_poll() races
From: Al Viro aio_poll() has to cope with several unpleasant problems: * requests that might stay around indefinitely need to be made visible for io_cancel(2); that must not be done to a request already completed, though. * in cases when ->poll() has placed us on a waitqueue, wakeup might have happened (and request completed) before ->poll() returns. * worse, in some early wakeup cases request might end up re-added into the queue later - we can't treat "woken up and currently not in the queue" as "it's not going to stick around indefinitely" * ... moreover, ->poll() might have decided not to put it on any queues to start with, and that needs to be distinguished from the previous case * ->poll() might have tried to put us on more than one queue. Only the first will succeed for aio poll, so we might end up missing wakeups. OTOH, we might very well notice that only after the wakeup hits and request gets completed (all before ->poll() gets around to the second poll_wait()). In that case it's too late to decide that we have an error. req->woken was an attempt to deal with that. Unfortunately, it was broken. What we need to keep track of is not that wakeup has happened - the thing might come back after that. It's that async reference is already gone and won't come back, so we can't (and needn't) put the request on the list of cancellables. The easiest case is "request hadn't been put on any waitqueues"; we can tell by seeing NULL apt.head, and in that case there won't be anything async. We should either complete the request ourselves (if vfs_poll() reports anything of interest) or return an error. In all other cases we get exclusion with wakeups by grabbing the queue lock. If request is currently on queue and we have something interesting from vfs_poll(), we can steal it and complete the request ourselves. If it's on queue and vfs_poll() has not reported anything interesting, we either put it on the cancellable list, or, if we know that it hadn't been put on all queues ->poll() wanted it on, we steal it and return an error. If it's _not_ on queue, it's either been already dealt with (in which case we do nothing), or there's aio_poll_complete_work() about to be executed. In that case we either put it on the cancellable list, or, if we know it hadn't been put on all queues ->poll() wanted it on, simulate what cancel would've done. It's a lot more convoluted than I'd like it to be. Single-consumer APIs suck, and unfortunately aio is not an exception... Signed-off-by: Al Viro --- fs/aio.c | 71 +--- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index b9c4c1894020..f47a29f7f201 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -181,7 +181,7 @@ struct poll_iocb { struct file *file; struct wait_queue_head *head; __poll_tevents; - boolwoken; + booldone; boolcancelled; struct wait_queue_entry wait; struct work_struct work; @@ -1606,12 +1606,6 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, return 0; } -static inline void aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask) -{ - iocb->ki_res.res = mangle_poll(mask); - iocb_put(iocb); -} - static void aio_poll_complete_work(struct work_struct *work) { struct poll_iocb *req = container_of(work, struct poll_iocb, work); @@ -1637,9 +1631,11 @@ static void aio_poll_complete_work(struct work_struct *work) return; } list_del_init(>ki_list); + iocb->ki_res.res = mangle_poll(mask); + req->done = true; spin_unlock_irq(>ctx_lock); - aio_poll_complete(iocb, mask); + iocb_put(iocb); } /* assumes we are called with irqs disabled */ @@ -1671,7 +1667,7 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, if (mask && !(mask & req->events)) return 0; - req->woken = true; + list_del_init(>wait.entry); if (mask) { /* @@ -1682,15 +1678,14 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, */ if (spin_trylock_irqsave(>ki_ctx->ctx_lock, flags)) { list_del(>ki_list); + iocb->ki_res.res = mangle_poll(mask); + req->done = true; spin_unlock_irqrestore(>ki_ctx->ctx_lock, flags); - - list_del_init(>wait.entry); - aio_poll_complete(iocb, mask); + iocb_put(iocb); return 1; } } - list_del_init(>wait.entry); schedule_work(>work); return 1; } @@ -1723,6 +1718,7 @@ static ssize_t
[PATCH 5/8] make aio_read()/aio_write() return int
From: Al Viro that ssize_t is a rudiment of earlier calling conventions; it's been used only to pass 0 and -E... since last autumn. Signed-off-by: Al Viro --- fs/aio.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index f47a29f7f201..f9e8f1edfe36 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1513,13 +1513,13 @@ static inline void aio_rw_done(struct kiocb *req, ssize_t ret) } } -static ssize_t aio_read(struct kiocb *req, const struct iocb *iocb, +static int aio_read(struct kiocb *req, const struct iocb *iocb, bool vectored, bool compat) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; struct iov_iter iter; struct file *file; - ssize_t ret; + int ret; ret = aio_prep_rw(req, iocb); if (ret) @@ -1541,13 +1541,13 @@ static ssize_t aio_read(struct kiocb *req, const struct iocb *iocb, return ret; } -static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb, +static int aio_write(struct kiocb *req, const struct iocb *iocb, bool vectored, bool compat) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; struct iov_iter iter; struct file *file; - ssize_t ret; + int ret; ret = aio_prep_rw(req, iocb); if (ret) @@ -1713,7 +1713,7 @@ aio_poll_queue_proc(struct file *file, struct wait_queue_head *head, add_wait_queue(head, >iocb->poll.wait); } -static ssize_t aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) +static int aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) { struct kioctx *ctx = aiocb->ki_ctx; struct poll_iocb *req = >poll; @@ -1778,7 +1778,7 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, struct iocb __user *user_iocb, bool compat) { struct aio_kiocb *req; - ssize_t ret; + int ret; /* enforce forwards compatibility on users */ if (unlikely(iocb->aio_reserved2)) { -- 2.11.0
[PATCH 3/8] aio: store event at final iocb_put()
From: Al Viro Instead of having aio_complete() set ->ki_res.{res,res2}, do that explicitly in its callers, drop the reference (as aio_complete() used to do) and delay the rest until the final iocb_put(). Signed-off-by: Al Viro --- fs/aio.c | 45 - 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 2249a7a1d6b3..b9c4c1894020 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1077,24 +1077,10 @@ static inline void iocb_destroy(struct aio_kiocb *iocb) kmem_cache_free(kiocb_cachep, iocb); } -static inline void iocb_put(struct aio_kiocb *iocb) -{ - if (refcount_dec_and_test(>ki_refcnt)) - iocb_destroy(iocb); -} - -static void aio_fill_event(struct io_event *ev, struct aio_kiocb *iocb, - long res, long res2) -{ - iocb->ki_res.res = res; - iocb->ki_res.res2 = res2; - *ev = iocb->ki_res; -} - /* aio_complete * Called when the io request on the given iocb is complete. */ -static void aio_complete(struct aio_kiocb *iocb, long res, long res2) +static void aio_complete(struct aio_kiocb *iocb) { struct kioctx *ctx = iocb->ki_ctx; struct aio_ring *ring; @@ -1118,14 +1104,14 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) ev_page = kmap_atomic(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]); event = ev_page + pos % AIO_EVENTS_PER_PAGE; - aio_fill_event(event, iocb, res, res2); + *event = iocb->ki_res; kunmap_atomic(ev_page); flush_dcache_page(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]); - pr_debug("%p[%u]: %p: %p %Lx %lx %lx\n", + pr_debug("%p[%u]: %p: %p %Lx %Lx %Lx\n", ctx, tail, iocb, (void __user *)iocb->ki_res.obj, iocb->ki_res.data, -res, res2); +iocb->ki_res.res, iocb->ki_res.res2); /* after flagging the request as done, we * must never even look at it again @@ -1167,7 +1153,14 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) if (waitqueue_active(>wait)) wake_up(>wait); - iocb_put(iocb); +} + +static inline void iocb_put(struct aio_kiocb *iocb) +{ + if (refcount_dec_and_test(>ki_refcnt)) { + aio_complete(iocb); + iocb_destroy(iocb); + } } /* aio_read_events_ring @@ -1441,7 +1434,9 @@ static void aio_complete_rw(struct kiocb *kiocb, long res, long res2) file_end_write(kiocb->ki_filp); } - aio_complete(iocb, res, res2); + iocb->ki_res.res = res; + iocb->ki_res.res2 = res2; + iocb_put(iocb); } static int aio_prep_rw(struct kiocb *req, const struct iocb *iocb) @@ -1589,11 +1584,10 @@ static ssize_t aio_write(struct kiocb *req, const struct iocb *iocb, static void aio_fsync_work(struct work_struct *work) { - struct fsync_iocb *req = container_of(work, struct fsync_iocb, work); - int ret; + struct aio_kiocb *iocb = container_of(work, struct aio_kiocb, fsync.work); - ret = vfs_fsync(req->file, req->datasync); - aio_complete(container_of(req, struct aio_kiocb, fsync), ret, 0); + iocb->ki_res.res = vfs_fsync(iocb->fsync.file, iocb->fsync.datasync); + iocb_put(iocb); } static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, @@ -1614,7 +1608,8 @@ static int aio_fsync(struct fsync_iocb *req, const struct iocb *iocb, static inline void aio_poll_complete(struct aio_kiocb *iocb, __poll_t mask) { - aio_complete(iocb, mangle_poll(mask), 0); + iocb->ki_res.res = mangle_poll(mask); + iocb_put(iocb); } static void aio_poll_complete_work(struct work_struct *work) -- 2.11.0
[PATCH 2/8] keep io_event in aio_kiocb
From: Al Viro Signed-off-by: Al Viro --- fs/aio.c | 56 +--- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 363d7d7c8bff..2249a7a1d6b3 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -204,8 +204,7 @@ struct aio_kiocb { struct kioctx *ki_ctx; kiocb_cancel_fn *ki_cancel; - struct iocb __user *ki_user_iocb; /* user's aiocb */ - __u64 ki_user_data; /* user's data for completion */ + struct io_event ki_res; struct list_headki_list;/* the aio core uses this * for cancellation */ @@ -1087,10 +1086,9 @@ static inline void iocb_put(struct aio_kiocb *iocb) static void aio_fill_event(struct io_event *ev, struct aio_kiocb *iocb, long res, long res2) { - ev->obj = (u64)(unsigned long)iocb->ki_user_iocb; - ev->data = iocb->ki_user_data; - ev->res = res; - ev->res2 = res2; + iocb->ki_res.res = res; + iocb->ki_res.res2 = res2; + *ev = iocb->ki_res; } /* aio_complete @@ -1126,7 +1124,7 @@ static void aio_complete(struct aio_kiocb *iocb, long res, long res2) flush_dcache_page(ctx->ring_pages[pos / AIO_EVENTS_PER_PAGE]); pr_debug("%p[%u]: %p: %p %Lx %lx %lx\n", -ctx, tail, iocb, iocb->ki_user_iocb, iocb->ki_user_data, +ctx, tail, iocb, (void __user *)iocb->ki_res.obj, iocb->ki_res.data, res, res2); /* after flagging the request as done, we @@ -1674,13 +1672,13 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, __poll_t mask = key_to_poll(key); unsigned long flags; + /* for instances that support it check for an event match first: */ + if (mask && !(mask & req->events)) + return 0; + req->woken = true; - /* for instances that support it check for an event match first: */ if (mask) { - if (!(mask & req->events)) - return 0; - /* * Try to complete the iocb inline if we can. Use * irqsave/irqrestore because not all filesystems (e.g. fuse) @@ -1844,8 +1842,10 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, goto out_put_req; } - req->ki_user_iocb = user_iocb; - req->ki_user_data = iocb->aio_data; + req->ki_res.obj = (u64)(unsigned long)user_iocb; + req->ki_res.data = iocb->aio_data; + req->ki_res.res = 0; + req->ki_res.res2 = 0; switch (iocb->aio_lio_opcode) { case IOCB_CMD_PREAD: @@ -2002,24 +2002,6 @@ COMPAT_SYSCALL_DEFINE3(io_submit, compat_aio_context_t, ctx_id, } #endif -/* lookup_kiocb - * Finds a given iocb for cancellation. - */ -static struct aio_kiocb * -lookup_kiocb(struct kioctx *ctx, struct iocb __user *iocb) -{ - struct aio_kiocb *kiocb; - - assert_spin_locked(>ctx_lock); - - /* TODO: use a hash or array, this sucks. */ - list_for_each_entry(kiocb, >active_reqs, ki_list) { - if (kiocb->ki_user_iocb == iocb) - return kiocb; - } - return NULL; -} - /* sys_io_cancel: * Attempts to cancel an iocb previously passed to io_submit. If * the operation is successfully cancelled, the resulting event is @@ -2037,6 +2019,7 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb, struct aio_kiocb *kiocb; int ret = -EINVAL; u32 key; + u64 obj = (u64)(unsigned long)iocb; if (unlikely(get_user(key, >aio_key))) return -EFAULT; @@ -2048,10 +2031,13 @@ SYSCALL_DEFINE3(io_cancel, aio_context_t, ctx_id, struct iocb __user *, iocb, return -EINVAL; spin_lock_irq(>ctx_lock); - kiocb = lookup_kiocb(ctx, iocb); - if (kiocb) { - ret = kiocb->ki_cancel(>rw); - list_del_init(>ki_list); + /* TODO: use a hash or array, this sucks. */ + list_for_each_entry(kiocb, >active_reqs, ki_list) { + if (kiocb->ki_res.obj == obj) { + ret = kiocb->ki_cancel(>rw); + list_del_init(>ki_list); + break; + } } spin_unlock_irq(>ctx_lock); -- 2.11.0
[PATCH 1/8] pin iocb through aio.
From: Linus Torvalds aio_poll() is not the only case that needs file pinned; worse, while aio_read()/aio_write() can live without pinning iocb itself, the proof is rather brittle and can easily break on later changes. Signed-off-by: Linus Torvalds Signed-off-by: Al Viro --- fs/aio.c | 37 + 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 3d9669d011b9..363d7d7c8bff 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1022,6 +1022,9 @@ static bool get_reqs_available(struct kioctx *ctx) /* aio_get_req * Allocate a slot for an aio request. * Returns NULL if no requests are free. + * + * The refcount is initialized to 2 - one for the async op completion, + * one for the synchronous code that does this. */ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) { @@ -1034,7 +1037,7 @@ static inline struct aio_kiocb *aio_get_req(struct kioctx *ctx) percpu_ref_get(>reqs); req->ki_ctx = ctx; INIT_LIST_HEAD(>ki_list); - refcount_set(>ki_refcnt, 0); + refcount_set(>ki_refcnt, 2); req->ki_eventfd = NULL; return req; } @@ -1067,15 +1070,18 @@ static struct kioctx *lookup_ioctx(unsigned long ctx_id) return ret; } +static inline void iocb_destroy(struct aio_kiocb *iocb) +{ + if (iocb->ki_filp) + fput(iocb->ki_filp); + percpu_ref_put(>ki_ctx->reqs); + kmem_cache_free(kiocb_cachep, iocb); +} + static inline void iocb_put(struct aio_kiocb *iocb) { - if (refcount_read(>ki_refcnt) == 0 || - refcount_dec_and_test(>ki_refcnt)) { - if (iocb->ki_filp) - fput(iocb->ki_filp); - percpu_ref_put(>ki_ctx->reqs); - kmem_cache_free(kiocb_cachep, iocb); - } + if (refcount_dec_and_test(>ki_refcnt)) + iocb_destroy(iocb); } static void aio_fill_event(struct io_event *ev, struct aio_kiocb *iocb, @@ -1749,9 +1755,6 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) INIT_LIST_HEAD(>wait.entry); init_waitqueue_func_entry(>wait, aio_poll_wake); - /* one for removal from waitqueue, one for this function */ - refcount_set(>ki_refcnt, 2); - mask = vfs_poll(req->file, ) & req->events; if (unlikely(!req->head)) { /* we did not manage to set up a waitqueue, done */ @@ -1782,7 +1785,6 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, const struct iocb *iocb) if (mask) aio_poll_complete(aiocb, mask); - iocb_put(aiocb); return 0; } @@ -1873,18 +1875,21 @@ static int __io_submit_one(struct kioctx *ctx, const struct iocb *iocb, break; } + /* Done with the synchronous reference */ + iocb_put(req); + /* * If ret is 0, we'd either done aio_complete() ourselves or have * arranged for that to be done asynchronously. Anything non-zero * means that we need to destroy req ourselves. */ - if (ret) - goto out_put_req; - return 0; + if (!ret) + return 0; + out_put_req: if (req->ki_eventfd) eventfd_ctx_put(req->ki_eventfd); - iocb_put(req); + iocb_destroy(req); out_put_reqs_available: put_reqs_available(ctx, 1); return ret; -- 2.11.0
Re: [PATCH 1/8] aio: make sure file is pinned
On Fri, Mar 08, 2019 at 03:36:50AM +, Al Viro wrote: > See vfs.git#work.aio; the crucial bits are in these commits: > keep io_event in aio_kiocb > get rid of aio_complete() res/res2 arguments > move aio_complete() to final iocb_put(), try to fix aio_poll() logics > The first two are preparations, the last is where the fixes (hopefully) > happen. OK, refactored, cleaned up and force-pushed. Current state: Al Viro (7): keep io_event in aio_kiocb aio: store event at final iocb_put() Fix aio_poll() races make aio_read()/aio_write() return int move dropping ->ki_eventfd into iocb_destroy() deal with get_reqs_available() in aio_get_req() itself aio: move sanity checks and request allocation to io_submit_one() Linus Torvalds (1): pin iocb through aio. fs/aio.c | 327 --- 1 file changed, 146 insertions(+), 181 deletions(-)
Re: [PATCH net] net: hns3: fix to stop multiple HNS reset due to the AER changes
From: Huazhong Tan Date: Sun, 10 Mar 2019 14:47:51 +0800 > From: Shiju Jose > > The commit bfcb79fca19d > ("PCI/ERR: Run error recovery callbacks for all affected devices") > affected the non-fatal error recovery logic for the HNS and RDMA devices. > This is because each HNS PF under PCIe bus receive callbacks > from the AER driver when an error is reported for one of the PF. > This causes unwanted PF resets because > the HNS decides which PF to reset based on the reset type set. > The HNS error handling code sets the reset type based on the hw error > type detected. > > This patch provides fix for the above issue for the recovery of > the hw errors in the HNS and RDMA devices. > > This patch needs backporting to the kernel v5.0+ > > Fixes: 332fbf576579 ("net: hns3: add handling of hw ras errors using new set > of commands") > Reported-by: Xiaofei Tan > Signed-off-by: Shiju Jose > Signed-off-by: Huazhong Tan Applied and queued up for -stable, thanks.
Re: Linux 5.0.1
diff --git a/Makefile b/Makefile index d5713e7b1e50..3cd7163fe164 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 5 PATCHLEVEL = 0 -SUBLEVEL = 0 +SUBLEVEL = 1 EXTRAVERSION = NAME = Shy Crocodile diff --git a/arch/alpha/kernel/syscalls/syscall.tbl b/arch/alpha/kernel/syscalls/syscall.tbl index 7b56a53be5e3..e09558edae73 100644 --- a/arch/alpha/kernel/syscalls/syscall.tbl +++ b/arch/alpha/kernel/syscalls/syscall.tbl @@ -451,3 +451,4 @@ 520common preadv2 sys_preadv2 521common pwritev2sys_pwritev2 522common statx sys_statx +523common io_pgetevents sys_io_pgetevents diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index ba150c755fcc..85b6c60f285d 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -52,6 +52,7 @@ asmlinkage void spurious_interrupt(void) void __init init_IRQ(void) { int i; + unsigned int order = get_order(IRQ_STACK_SIZE); for (i = 0; i < NR_IRQS; i++) irq_set_noprobe(i); @@ -62,8 +63,7 @@ void __init init_IRQ(void) arch_init_irq(); for_each_possible_cpu(i) { - int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE; - void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages); + void *s = (void *)__get_free_pages(GFP_KERNEL, order); irq_stack[i] = s; pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i, diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c index 9e2157371491..f8debf7aeb4c 100644 --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -1,5 +1,7 @@ +#include #include #include +#include #include "pgtable.h" #include "../string.h" @@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char *option); static unsigned long find_trampoline_placement(void) { - unsigned long bios_start, ebda_start; + unsigned long bios_start = 0, ebda_start = 0; unsigned long trampoline_start; struct boot_e820_entry *entry; + char *signature; int i; /* @@ -47,8 +50,18 @@ static unsigned long find_trampoline_placement(void) * This code is based on reserve_bios_regions(). */ - ebda_start = *(unsigned short *)0x40e << 4; - bios_start = *(unsigned short *)0x413 << 10; + /* +* EFI systems may not provide legacy ROM. The memory may not be mapped +* at all. +* +* Only look for values in the legacy ROM for non-EFI system. +*/ + signature = (char *)_params->efi_info.efi_loader_signature; + if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) && + strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) { + ebda_start = *(unsigned short *)0x40e << 4; + bios_start = *(unsigned short *)0x413 << 10; + } if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX) bios_start = BIOS_START_MAX; diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 69f6bbb41be0..01004bfb1a1b 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -819,11 +819,9 @@ static void init_amd_bd(struct cpuinfo_x86 *c) static void init_amd_zn(struct cpuinfo_x86 *c) { set_cpu_cap(c, X86_FEATURE_ZEN); - /* -* Fix erratum 1076: CPB feature bit not being set in CPUID. It affects -* all up to and including B1. -*/ - if (c->x86_model <= 1 && c->x86_stepping <= 1) + + /* Fix erratum 1076: CPB feature bit not being set in CPUID. */ + if (!cpu_has(c, X86_FEATURE_CPB)) set_cpu_cap(c, X86_FEATURE_CPB); } diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 74969a437a37..2e73395f0560 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -321,8 +321,8 @@ unsigned long get_wchan(struct task_struct *p) /* Stack layout: sp-4: ra, sp-3: sp' */ - pc = MAKE_PC_FROM_RA(*(unsigned long*)sp - 4, sp); - sp = *(unsigned long *)sp - 3; + pc = MAKE_PC_FROM_RA(SPILL_SLOT(sp, 0), sp); + sp = SPILL_SLOT(sp, 1); } while (count++ < 16); return 0; } diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 4d2b2ad1ee0e..01f80cbd2741 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -329,6 +329,8 @@ struct binder_error { *(invariant after initialized) * @min_priority: minimum scheduling priority *(invariant after initialized) + * @txn_security_ctx: require sender's security context + *(invariant after initialized) * @async_todo: list of async work items *(protected by
Re: Linux 5.0.1
On Sun, Mar 10, 2019 at 07:52:03AM +0100, Greg KH wrote: > On Sun, Mar 10, 2019 at 07:51:10AM +0100, Greg KH wrote: > > I'm announcing the release of the 5.0.1 kernel. > > > > All users of the 5.0.1 kernel series must upgrade. > > > > The updated 5.0.1.y git tree can be found at: > > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git > > linux-5.0.1.y > > and can be browsed at the normal kernel.org git web browser: > > > > http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary > > > > thanks, > > > > greg k-h > > > > > > > > Makefile |2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Ugh, something went obviously wrong here with my scripts, that's not > good... Ok, the release was made correctly, my local scripts didn't know about "5.x" yet, when making the email messages up. Here's the "real" diffstat and release announcement: - I'm announcing the release of the 5.0.1 kernel. All users of the 5.0 kernel series must upgrade. The updated 5.0.y git tree can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-5.0.y and can be browsed at the normal kernel.org git web browser: http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary thanks, greg k-h Makefile |2 arch/alpha/kernel/syscalls/syscall.tbl|1 arch/mips/kernel/irq.c|4 arch/x86/boot/compressed/pgtable_64.c | 19 +++ arch/x86/kernel/cpu/amd.c |8 - arch/xtensa/kernel/process.c |4 drivers/android/binder.c | 106 +- drivers/base/dd.c |2 drivers/bluetooth/btrtl.c | 10 +- drivers/char/applicom.c | 35 --- drivers/cpufreq/cpufreq.c |6 - drivers/cpufreq/intel_pstate.c| 23 ++-- drivers/gnss/sirf.c | 32 +++--- drivers/net/dsa/mv88e6xxx/chip.c | 13 +- drivers/net/dsa/mv88e6xxx/port.c |2 drivers/net/ethernet/marvell/sky2.c | 24 drivers/net/ethernet/mscc/ocelot_board.c | 14 ++ drivers/net/team/team_mode_loadbalance.c | 15 +++ drivers/net/usb/qmi_wwan.c| 26 +++-- drivers/staging/android/ashmem.c | 67 + drivers/staging/android/ion/ion_system_heap.c |2 drivers/staging/comedi/drivers/ni_660x.c |1 drivers/staging/erofs/inode.c |8 - drivers/staging/erofs/internal.h | 11 +- drivers/staging/erofs/unzip_vle.c | 77 ++- drivers/staging/erofs/xattr.c | 65 ++--- drivers/staging/wilc1000/linux_wlan.c |4 drivers/usb/host/xhci-pci.c |1 drivers/usb/host/xhci-tegra.c |4 drivers/usb/serial/cp210x.c | 12 ++ drivers/usb/serial/ftdi_sio.c |2 drivers/usb/serial/ftdi_sio_ids.h |6 + drivers/usb/serial/option.c |2 fs/aio.c | 12 +- fs/exec.c |2 include/linux/cpufreq.h | 12 -- include/net/bluetooth/bluetooth.h |2 include/net/sch_generic.h | 31 ++ include/uapi/linux/android/binder.h | 19 +++ kernel/trace/trace_events_filter.c|5 - net/bluetooth/af_bluetooth.c | 16 ++- net/bluetooth/l2cap_sock.c|2 net/bluetooth/rfcomm/sock.c |2 net/bluetooth/sco.c |2 net/core/gen_stats.c |2 net/core/net-sysfs.c |3 net/ipv6/ip6mr.c |8 - net/sched/sch_generic.c | 13 +- net/sctp/socket.c |1 net/tipc/socket.c |2 tools/testing/selftests/firmware/config |1 tools/testing/selftests/firmware/fw_filesystem.sh |9 + tools/testing/selftests/firmware/fw_lib.sh|2 53 files changed, 520 insertions(+), 234 deletions(-) Ajay Singh (1): staging: wilc1000: fix to set correct value for 'vif_num' Arnd Bergmann (1): alpha: wire up io_pgetevents system call Balaji Manoharan (1): usb: xhci: Fix for Enabling USB ROLE SWITCH QUIRK on INTEL_SUNRISEPOINT_LP_XHCI Bart Van Assche (1): aio: Fix locking in aio_poll() Daniele
Re: Linux 4.20.15
diff --git a/Makefile b/Makefile index f7baaa0a3164..25b45c24bac0 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 4 PATCHLEVEL = 20 -SUBLEVEL = 14 +SUBLEVEL = 15 EXTRAVERSION = NAME = Shy Crocodile diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index ba150c755fcc..85b6c60f285d 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -52,6 +52,7 @@ asmlinkage void spurious_interrupt(void) void __init init_IRQ(void) { int i; + unsigned int order = get_order(IRQ_STACK_SIZE); for (i = 0; i < NR_IRQS; i++) irq_set_noprobe(i); @@ -62,8 +63,7 @@ void __init init_IRQ(void) arch_init_irq(); for_each_possible_cpu(i) { - int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE; - void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages); + void *s = (void *)__get_free_pages(GFP_KERNEL, order); irq_stack[i] = s; pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i, diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c index 9e2157371491..f8debf7aeb4c 100644 --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -1,5 +1,7 @@ +#include #include #include +#include #include "pgtable.h" #include "../string.h" @@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char *option); static unsigned long find_trampoline_placement(void) { - unsigned long bios_start, ebda_start; + unsigned long bios_start = 0, ebda_start = 0; unsigned long trampoline_start; struct boot_e820_entry *entry; + char *signature; int i; /* @@ -47,8 +50,18 @@ static unsigned long find_trampoline_placement(void) * This code is based on reserve_bios_regions(). */ - ebda_start = *(unsigned short *)0x40e << 4; - bios_start = *(unsigned short *)0x413 << 10; + /* +* EFI systems may not provide legacy ROM. The memory may not be mapped +* at all. +* +* Only look for values in the legacy ROM for non-EFI system. +*/ + signature = (char *)_params->efi_info.efi_loader_signature; + if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) && + strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) { + ebda_start = *(unsigned short *)0x40e << 4; + bios_start = *(unsigned short *)0x413 << 10; + } if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX) bios_start = BIOS_START_MAX; diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index eeea634bee0a..6a25278e0092 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -818,11 +818,9 @@ static void init_amd_bd(struct cpuinfo_x86 *c) static void init_amd_zn(struct cpuinfo_x86 *c) { set_cpu_cap(c, X86_FEATURE_ZEN); - /* -* Fix erratum 1076: CPB feature bit not being set in CPUID. It affects -* all up to and including B1. -*/ - if (c->x86_model <= 1 && c->x86_stepping <= 1) + + /* Fix erratum 1076: CPB feature bit not being set in CPUID. */ + if (!cpu_has(c, X86_FEATURE_CPB)) set_cpu_cap(c, X86_FEATURE_CPB); } diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 4bb68133a72a..5a0e0bd68b76 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -320,8 +320,8 @@ unsigned long get_wchan(struct task_struct *p) /* Stack layout: sp-4: ra, sp-3: sp' */ - pc = MAKE_PC_FROM_RA(*(unsigned long*)sp - 4, sp); - sp = *(unsigned long *)sp - 3; + pc = MAKE_PC_FROM_RA(SPILL_SLOT(sp, 0), sp); + sp = SPILL_SLOT(sp, 1); } while (count++ < 16); return 0; } diff --git a/drivers/android/binder.c b/drivers/android/binder.c index b834ee335d9a..6d5f3aca8e9c 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -356,6 +356,8 @@ struct binder_error { *(invariant after initialized) * @min_priority: minimum scheduling priority *(invariant after initialized) + * @txn_security_ctx: require sender's security context + *(invariant after initialized) * @async_todo: list of async work items *(protected by @proc->inner_lock) * @@ -392,6 +394,7 @@ struct binder_node { * invariant after initialization */ u8 accept_fds:1; + u8 txn_security_ctx:1; u8 min_priority; }; bool has_async_transaction; @@ -642,6 +645,7 @@ struct binder_transaction { longsaved_priority; kuid_t sender_euid; struct list_head fd_fixups; + binder_uintptr_t security_ctx; /**
Linux 4.19.28
I'm announcing the release of the 4.19.28 kernel. All users of the 4.19 kernel series must upgrade. The updated 4.19.y git tree can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.19.y and can be browsed at the normal kernel.org git web browser: http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary thanks, greg k-h Makefile |2 arch/mips/kernel/irq.c|4 arch/x86/boot/compressed/pgtable_64.c | 19 +++- arch/x86/kernel/cpu/amd.c |8 - arch/xtensa/kernel/process.c |4 drivers/bluetooth/btrtl.c | 10 +- drivers/char/applicom.c | 35 +-- drivers/cpufreq/cpufreq.c |6 - drivers/cpufreq/intel_pstate.c| 23 ++--- drivers/gnss/sirf.c | 32 +++ drivers/net/dsa/mv88e6xxx/chip.c | 26 - drivers/net/dsa/mv88e6xxx/port.c | 10 +- drivers/net/dsa/mv88e6xxx/port.h |1 drivers/net/ethernet/broadcom/bnxt/bnxt.c |6 + drivers/net/ethernet/marvell/sky2.c | 24 + drivers/net/ethernet/microchip/lan743x_main.c | 16 ++- drivers/net/geneve.c | 11 +- drivers/net/hyperv/netvsc_drv.c | 22 - drivers/net/phy/micrel.c | 13 ++ drivers/net/phy/phylink.c |4 drivers/net/team/team_mode_loadbalance.c | 15 +++ drivers/net/tun.c |4 drivers/net/usb/qmi_wwan.c| 26 - drivers/net/xen-netback/hash.c|2 drivers/net/xen-netback/interface.c |7 + drivers/net/xen-netback/netback.c | 10 +- drivers/scsi/scsi_lib.c |1 drivers/staging/android/ashmem.c | 67 ++- drivers/staging/android/ion/ion_system_heap.c |2 drivers/staging/comedi/drivers/ni_660x.c |1 drivers/staging/erofs/unzip_vle.c | 114 +++--- drivers/staging/erofs/unzip_vle.h |3 drivers/staging/erofs/unzip_vle_lz4.c | 20 ++-- drivers/staging/wilc1000/linux_wlan.c |4 drivers/usb/host/xhci-pci.c |1 drivers/usb/serial/cp210x.c | 12 ++ drivers/usb/serial/ftdi_sio.c |2 drivers/usb/serial/ftdi_sio_ids.h |6 + drivers/usb/serial/option.c |2 fs/aio.c | 12 ++ fs/exec.c |2 include/linux/cpufreq.h | 12 -- include/net/bluetooth/bluetooth.h |2 include/net/icmp.h|9 +- include/net/ip.h |4 include/net/sch_generic.h | 31 ++- kernel/bpf/verifier.c |3 kernel/trace/trace_events_filter.c|5 - net/bluetooth/af_bluetooth.c | 16 ++- net/bluetooth/l2cap_sock.c|2 net/bluetooth/rfcomm/sock.c |2 net/bluetooth/sco.c |2 net/core/gen_stats.c |2 net/core/net-sysfs.c |3 net/ipv4/cipso_ipv4.c | 20 +++- net/ipv4/fib_frontend.c |4 net/ipv4/icmp.c |7 - net/ipv4/ip_input.c |9 +- net/ipv4/ip_options.c | 22 +++-- net/ipv4/netlink.c| 17 ++- net/ipv4/route.c |2 net/ipv6/ip6mr.c |8 - net/ipv6/route.c |7 + net/ipv6/sit.c|1 net/mpls/af_mpls.c|3 net/netlabel/netlabel_kapi.c |3 net/nfc/llcp_commands.c | 20 net/nfc/llcp_core.c | 24 - net/sched/act_ipt.c |3 net/sched/act_skbedit.c |3 net/sched/act_tunnel_key.c|3 net/sched/sch_generic.c | 13 +- net/sched/sch_netem.c | 10 +- net/sctp/socket.c |1 net/socket.c |1 net/tipc/socket.c |8 + tools/testing/selftests/firmware/fw_lib.sh|2 77 files changed, 603 insertions(+), 270 deletions(-) Ajay Singh (1): staging: wilc1000: fix to set correct value for 'vif_num' Andrew Lunn (2): net: dsa: mv88e6xxx: Fix
Re: Linux 4.19.28
diff --git a/Makefile b/Makefile index 70ed9a53558a..c6ac023ba33a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 VERSION = 4 PATCHLEVEL = 19 -SUBLEVEL = 27 +SUBLEVEL = 28 EXTRAVERSION = NAME = "People's Front" diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c index ba150c755fcc..85b6c60f285d 100644 --- a/arch/mips/kernel/irq.c +++ b/arch/mips/kernel/irq.c @@ -52,6 +52,7 @@ asmlinkage void spurious_interrupt(void) void __init init_IRQ(void) { int i; + unsigned int order = get_order(IRQ_STACK_SIZE); for (i = 0; i < NR_IRQS; i++) irq_set_noprobe(i); @@ -62,8 +63,7 @@ void __init init_IRQ(void) arch_init_irq(); for_each_possible_cpu(i) { - int irq_pages = IRQ_STACK_SIZE / PAGE_SIZE; - void *s = (void *)__get_free_pages(GFP_KERNEL, irq_pages); + void *s = (void *)__get_free_pages(GFP_KERNEL, order); irq_stack[i] = s; pr_debug("CPU%d IRQ stack at 0x%p - 0x%p\n", i, diff --git a/arch/x86/boot/compressed/pgtable_64.c b/arch/x86/boot/compressed/pgtable_64.c index 9e2157371491..f8debf7aeb4c 100644 --- a/arch/x86/boot/compressed/pgtable_64.c +++ b/arch/x86/boot/compressed/pgtable_64.c @@ -1,5 +1,7 @@ +#include #include #include +#include #include "pgtable.h" #include "../string.h" @@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char *option); static unsigned long find_trampoline_placement(void) { - unsigned long bios_start, ebda_start; + unsigned long bios_start = 0, ebda_start = 0; unsigned long trampoline_start; struct boot_e820_entry *entry; + char *signature; int i; /* @@ -47,8 +50,18 @@ static unsigned long find_trampoline_placement(void) * This code is based on reserve_bios_regions(). */ - ebda_start = *(unsigned short *)0x40e << 4; - bios_start = *(unsigned short *)0x413 << 10; + /* +* EFI systems may not provide legacy ROM. The memory may not be mapped +* at all. +* +* Only look for values in the legacy ROM for non-EFI system. +*/ + signature = (char *)_params->efi_info.efi_loader_signature; + if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) && + strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) { + ebda_start = *(unsigned short *)0x40e << 4; + bios_start = *(unsigned short *)0x413 << 10; + } if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX) bios_start = BIOS_START_MAX; diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index eeea634bee0a..6a25278e0092 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -818,11 +818,9 @@ static void init_amd_bd(struct cpuinfo_x86 *c) static void init_amd_zn(struct cpuinfo_x86 *c) { set_cpu_cap(c, X86_FEATURE_ZEN); - /* -* Fix erratum 1076: CPB feature bit not being set in CPUID. It affects -* all up to and including B1. -*/ - if (c->x86_model <= 1 && c->x86_stepping <= 1) + + /* Fix erratum 1076: CPB feature bit not being set in CPUID. */ + if (!cpu_has(c, X86_FEATURE_CPB)) set_cpu_cap(c, X86_FEATURE_CPB); } diff --git a/arch/xtensa/kernel/process.c b/arch/xtensa/kernel/process.c index 4bb68133a72a..5a0e0bd68b76 100644 --- a/arch/xtensa/kernel/process.c +++ b/arch/xtensa/kernel/process.c @@ -320,8 +320,8 @@ unsigned long get_wchan(struct task_struct *p) /* Stack layout: sp-4: ra, sp-3: sp' */ - pc = MAKE_PC_FROM_RA(*(unsigned long*)sp - 4, sp); - sp = *(unsigned long *)sp - 3; + pc = MAKE_PC_FROM_RA(SPILL_SLOT(sp, 0), sp); + sp = SPILL_SLOT(sp, 1); } while (count++ < 16); return 0; } diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index 7f9ea8e4c1b2..1342f8e6025c 100644 --- a/drivers/bluetooth/btrtl.c +++ b/drivers/bluetooth/btrtl.c @@ -544,10 +544,9 @@ struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev, hdev->bus); if (!btrtl_dev->ic_info) { - rtl_dev_err(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x", + rtl_dev_info(hdev, "rtl: unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x", lmp_subver, hci_rev, hci_ver); - ret = -EINVAL; - goto err_free; + return btrtl_dev; } if (btrtl_dev->ic_info->has_rom_version) { @@ -602,6 +601,11 @@ int btrtl_download_firmware(struct hci_dev *hdev, * standard btusb. Once that firmware is uploaded, the subver changes * to a different value. */ + if (!btrtl_dev->ic_info) { + rtl_dev_info(hdev, "rtl: assuming no firmware upload
Linux 4.20.15
I'm announcing the release of the 4.20.15 kernel. All users of the 4.20 kernel series must upgrade. The updated 4.20.y git tree can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-4.20.y and can be browsed at the normal kernel.org git web browser: http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary thanks, greg k-h Makefile |2 arch/mips/kernel/irq.c|4 arch/x86/boot/compressed/pgtable_64.c | 19 +++- arch/x86/kernel/cpu/amd.c |8 - arch/xtensa/kernel/process.c |4 drivers/android/binder.c | 106 ++- drivers/base/dd.c |2 drivers/bluetooth/btrtl.c | 10 +- drivers/char/applicom.c | 35 +-- drivers/cpufreq/cpufreq.c |6 - drivers/cpufreq/intel_pstate.c| 23 ++--- drivers/gnss/sirf.c | 32 +++ drivers/net/dsa/mv88e6xxx/chip.c | 27 -- drivers/net/dsa/mv88e6xxx/port.c | 10 +- drivers/net/dsa/mv88e6xxx/port.h |1 drivers/net/ethernet/broadcom/bnxt/bnxt.c |6 + drivers/net/ethernet/marvell/sky2.c | 24 + drivers/net/ethernet/microchip/lan743x_main.c | 16 ++- drivers/net/ethernet/mscc/ocelot_board.c | 14 ++- drivers/net/geneve.c | 11 +- drivers/net/hyperv/netvsc_drv.c | 22 drivers/net/phy/micrel.c | 13 ++ drivers/net/phy/phylink.c |4 drivers/net/team/team_mode_loadbalance.c | 15 +++ drivers/net/tun.c |4 drivers/net/usb/qmi_wwan.c| 26 - drivers/net/xen-netback/hash.c|2 drivers/net/xen-netback/interface.c |7 + drivers/net/xen-netback/netback.c | 10 +- drivers/scsi/scsi_lib.c |1 drivers/staging/android/ashmem.c | 67 +-- drivers/staging/android/ion/ion_system_heap.c |2 drivers/staging/comedi/drivers/ni_660x.c |1 drivers/staging/erofs/inode.c |8 - drivers/staging/erofs/internal.h | 11 +- drivers/staging/erofs/unzip_vle.c | 115 -- drivers/staging/erofs/unzip_vle.h |3 drivers/staging/erofs/unzip_vle_lz4.c | 19 +--- drivers/staging/erofs/xattr.c | 65 +++--- drivers/staging/wilc1000/linux_wlan.c |4 drivers/usb/host/xhci-pci.c |1 drivers/usb/host/xhci-tegra.c |4 drivers/usb/serial/cp210x.c | 12 ++ drivers/usb/serial/ftdi_sio.c |2 drivers/usb/serial/ftdi_sio_ids.h |6 + drivers/usb/serial/option.c |2 fs/aio.c | 12 ++ fs/exec.c |2 include/linux/cpufreq.h | 12 -- include/net/bluetooth/bluetooth.h |2 include/net/icmp.h|9 +- include/net/ip.h |4 include/net/sch_generic.h | 31 ++- include/uapi/linux/android/binder.h | 19 kernel/bpf/verifier.c |3 kernel/trace/trace_events_filter.c|5 - net/bluetooth/af_bluetooth.c | 16 ++- net/bluetooth/l2cap_sock.c|2 net/bluetooth/rfcomm/sock.c |2 net/bluetooth/sco.c |2 net/core/gen_stats.c |2 net/core/net-sysfs.c |3 net/ipv4/cipso_ipv4.c | 20 +++- net/ipv4/fib_frontend.c |4 net/ipv4/icmp.c |7 - net/ipv4/ip_input.c |9 +- net/ipv4/ip_options.c | 22 +++- net/ipv4/netlink.c| 17 ++- net/ipv4/route.c |2 net/ipv6/ip6mr.c |8 - net/ipv6/route.c |7 + net/ipv6/sit.c|1 net/mpls/af_mpls.c|3 net/netlabel/netlabel_kapi.c |3 net/nfc/llcp_commands.c | 20 net/nfc/llcp_core.c | 24 - net/sched/act_ipt.c |3 net/sched/act_skbedit.c |3 net/sched/act_tunnel_key.c|3 net/sched/sch_generic.c
Re: Linux 5.0.1
On Sun, Mar 10, 2019 at 07:51:10AM +0100, Greg KH wrote: > I'm announcing the release of the 5.0.1 kernel. > > All users of the 5.0.1 kernel series must upgrade. > > The updated 5.0.1.y git tree can be found at: > git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git > linux-5.0.1.y > and can be browsed at the normal kernel.org git web browser: > > http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary > > thanks, > > greg k-h > > > > Makefile |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Ugh, something went obviously wrong here with my scripts, that's not good... greg k-h
Linux 5.0.1
I'm announcing the release of the 5.0.1 kernel. All users of the 5.0.1 kernel series must upgrade. The updated 5.0.1.y git tree can be found at: git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-5.0.1.y and can be browsed at the normal kernel.org git web browser: http://git.kernel.org/?p=linux/kernel/git/stable/linux-stable.git;a=summary thanks, greg k-h Makefile |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) signature.asc Description: PGP signature
[PATCH net] net: hns3: fix to stop multiple HNS reset due to the AER changes
From: Shiju Jose The commit bfcb79fca19d ("PCI/ERR: Run error recovery callbacks for all affected devices") affected the non-fatal error recovery logic for the HNS and RDMA devices. This is because each HNS PF under PCIe bus receive callbacks from the AER driver when an error is reported for one of the PF. This causes unwanted PF resets because the HNS decides which PF to reset based on the reset type set. The HNS error handling code sets the reset type based on the hw error type detected. This patch provides fix for the above issue for the recovery of the hw errors in the HNS and RDMA devices. This patch needs backporting to the kernel v5.0+ Fixes: 332fbf576579 ("net: hns3: add handling of hw ras errors using new set of commands") Reported-by: Xiaofei Tan Signed-off-by: Shiju Jose Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hnae3.h| 1 + drivers/net/ethernet/hisilicon/hns3/hns3_enet.c| 4 +++- drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c | 9 +++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 66d7a8b..38b430f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -194,6 +194,7 @@ struct hnae3_ae_dev { const struct hnae3_ae_ops *ops; struct list_head node; u32 flag; + u8 override_pci_need_reset; /* fix to stop multiple reset happening */ enum hnae3_dev_type dev_type; enum hnae3_reset_type reset_type; void *priv; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 0d1ae15..1c1f17e 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -1850,7 +1850,9 @@ static pci_ers_result_t hns3_slot_reset(struct pci_dev *pdev) /* request the reset */ if (ae_dev->ops->reset_event) { - ae_dev->ops->reset_event(pdev, NULL); + if (!ae_dev->override_pci_need_reset) + ae_dev->ops->reset_event(pdev, NULL); + return PCI_ERS_RESULT_RECOVERED; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c index 1feceff..1f52d11 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_err.c @@ -1317,8 +1317,10 @@ pci_ers_result_t hclge_handle_hw_ras_error(struct hnae3_ae_dev *ae_dev) hclge_handle_all_ras_errors(hdev); } else { if (test_bit(HCLGE_STATE_RST_HANDLING, >state) || - hdev->pdev->revision < 0x21) + hdev->pdev->revision < 0x21) { + ae_dev->override_pci_need_reset = 1; return PCI_ERS_RESULT_RECOVERED; + } } if (status & HCLGE_RAS_REG_ROCEE_ERR_MASK) { @@ -1327,8 +1329,11 @@ pci_ers_result_t hclge_handle_hw_ras_error(struct hnae3_ae_dev *ae_dev) } if (status & HCLGE_RAS_REG_NFE_MASK || - status & HCLGE_RAS_REG_ROCEE_ERR_MASK) + status & HCLGE_RAS_REG_ROCEE_ERR_MASK) { + ae_dev->override_pci_need_reset = 0; return PCI_ERS_RESULT_NEED_RESET; + } + ae_dev->override_pci_need_reset = 1; return PCI_ERS_RESULT_RECOVERED; } -- 2.7.4
Accept My Legit Grant.
Dear Friend, Greetings. I am Mrs Mavis Wanczyk the Powerball Lottery Winner of $ 758.7 Million. Click the below link to see about my winnings so that you know this is LEGITIMATE. https://edition.cnn.com/videos/us/2017/08/24/powerball-winner-massachusetts-quit-job-sot.wcvb/video/playlists/lottery-mania/ I intend to grant you a portion of my wealth as a free-will financial grant to you. Respond to sjjo...@mail.com to partake. IMPORTANT NOTE: Only mails sent to sjjo...@mail.com will be attend to. Best Regards, Mrs Mavis Wanczyk. SUPERPOP - Com muito bom humor, Luciana Gimenez discute temas polêmicos e curiosos. Clique aqui e veja o último programa. http://www.redetv.uol.com.br/superpop --- Usar papel é coisa do passado. Só imprima este e-mail caso seja imprescindível. Sendo moderno, você também ajuda a salvar o Planeta. ---
Re: [PATCH 5.0 30/46] x86/boot/compressed/64: Do not read legacy ROM on EFI system
On Sat, Mar 09, 2019 at 10:10:19PM -0800, h...@zytor.com wrote: > On March 8, 2019 4:50:03 AM PST, Greg Kroah-Hartman > wrote: > >5.0-stable review patch. If anyone has any objections, please let me > >know. > > > >-- > > > >From: Kirill A. Shutemov > > > >commit 6f913de3231e1d70a871135b38219da7810df218 upstream. > > > >EFI systems do not necessarily provide a legacy ROM. If the ROM is > >missing > >the memory is not mapped at all. > > > >Trying to dereference values in the legacy ROM area leads to a crash on > >Macbook Pro. > > > >Only look for values in the legacy ROM area for non-EFI system. > > > >Fixes: 3548e131ec6a ("x86/boot/compressed/64: Find a place for 32-bit > >trampoline") > >Reported-by: Pitam Mitra > >Signed-off-by: Kirill A. Shutemov > >Signed-off-by: Thomas Gleixner > >Tested-by: Bockjoo Kim > >Cc: b...@alien8.de > >Cc: h...@zytor.com > >Cc: sta...@vger.kernel.org > >Link: > >https://lkml.kernel.org/r/20190219075224.35058-1-kirill.shute...@linux.intel.com > >Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202351 > >Signed-off-by: Greg Kroah-Hartman > > > >--- > > arch/x86/boot/compressed/pgtable_64.c | 19 --- > > 1 file changed, 16 insertions(+), 3 deletions(-) > > > >--- a/arch/x86/boot/compressed/pgtable_64.c > >+++ b/arch/x86/boot/compressed/pgtable_64.c > >@@ -1,5 +1,7 @@ > >+#include > > #include > > #include > >+#include > > #include "pgtable.h" > > #include "../string.h" > > > >@@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char > > > > static unsigned long find_trampoline_placement(void) > > { > >-unsigned long bios_start, ebda_start; > >+unsigned long bios_start = 0, ebda_start = 0; > > unsigned long trampoline_start; > > struct boot_e820_entry *entry; > >+char *signature; > > int i; > > > > /* > >@@ -47,8 +50,18 @@ static unsigned long find_trampoline_pla > > * This code is based on reserve_bios_regions(). > > */ > > > >-ebda_start = *(unsigned short *)0x40e << 4; > >-bios_start = *(unsigned short *)0x413 << 10; > >+/* > >+ * EFI systems may not provide legacy ROM. The memory may not be > >mapped > >+ * at all. > >+ * > >+ * Only look for values in the legacy ROM for non-EFI system. > >+ */ > >+signature = (char *)_params->efi_info.efi_loader_signature; > >+if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) && > >+strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) { > >+ebda_start = *(unsigned short *)0x40e << 4; > >+bios_start = *(unsigned short *)0x413 << 10; > >+} > > > > if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX) > > bios_start = BIOS_START_MAX; > > Only one objection: the explanation is nonsensical. Heh, take it up with the original submitter, I don't change the changelog text after it hits Linus's tree :) greg k-h
Re: [PATCH 5.0 30/46] x86/boot/compressed/64: Do not read legacy ROM on EFI system
On March 8, 2019 4:50:03 AM PST, Greg Kroah-Hartman wrote: >5.0-stable review patch. If anyone has any objections, please let me >know. > >-- > >From: Kirill A. Shutemov > >commit 6f913de3231e1d70a871135b38219da7810df218 upstream. > >EFI systems do not necessarily provide a legacy ROM. If the ROM is >missing >the memory is not mapped at all. > >Trying to dereference values in the legacy ROM area leads to a crash on >Macbook Pro. > >Only look for values in the legacy ROM area for non-EFI system. > >Fixes: 3548e131ec6a ("x86/boot/compressed/64: Find a place for 32-bit >trampoline") >Reported-by: Pitam Mitra >Signed-off-by: Kirill A. Shutemov >Signed-off-by: Thomas Gleixner >Tested-by: Bockjoo Kim >Cc: b...@alien8.de >Cc: h...@zytor.com >Cc: sta...@vger.kernel.org >Link: >https://lkml.kernel.org/r/20190219075224.35058-1-kirill.shute...@linux.intel.com >Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202351 >Signed-off-by: Greg Kroah-Hartman > >--- > arch/x86/boot/compressed/pgtable_64.c | 19 --- > 1 file changed, 16 insertions(+), 3 deletions(-) > >--- a/arch/x86/boot/compressed/pgtable_64.c >+++ b/arch/x86/boot/compressed/pgtable_64.c >@@ -1,5 +1,7 @@ >+#include > #include > #include >+#include > #include "pgtable.h" > #include "../string.h" > >@@ -37,9 +39,10 @@ int cmdline_find_option_bool(const char > > static unsigned long find_trampoline_placement(void) > { >- unsigned long bios_start, ebda_start; >+ unsigned long bios_start = 0, ebda_start = 0; > unsigned long trampoline_start; > struct boot_e820_entry *entry; >+ char *signature; > int i; > > /* >@@ -47,8 +50,18 @@ static unsigned long find_trampoline_pla >* This code is based on reserve_bios_regions(). >*/ > >- ebda_start = *(unsigned short *)0x40e << 4; >- bios_start = *(unsigned short *)0x413 << 10; >+ /* >+ * EFI systems may not provide legacy ROM. The memory may not be >mapped >+ * at all. >+ * >+ * Only look for values in the legacy ROM for non-EFI system. >+ */ >+ signature = (char *)_params->efi_info.efi_loader_signature; >+ if (strncmp(signature, EFI32_LOADER_SIGNATURE, 4) && >+ strncmp(signature, EFI64_LOADER_SIGNATURE, 4)) { >+ ebda_start = *(unsigned short *)0x40e << 4; >+ bios_start = *(unsigned short *)0x413 << 10; >+ } > > if (bios_start < BIOS_START_MIN || bios_start > BIOS_START_MAX) > bios_start = BIOS_START_MAX; Only one objection: the explanation is nonsensical. -- Sent from my Android device with K-9 Mail. Please excuse my brevity.
Re: [PATCH 5.0 00/46] 5.0.1-stable review
On Sat, Mar 09, 2019 at 02:36:17PM -0800, Guenter Roeck wrote: > On 3/8/19 4:49 AM, Greg Kroah-Hartman wrote: > > This is the start of the stable review cycle for the 5.0.1 release. > > There are 46 patches in this series, all will be posted as a response > > to this one. If anyone has any issues with these being applied, please > > let me know. > > > > Responses should be made by Sun Mar 10 12:48:36 UTC 2019. > > Anything received after that time might be too late. > > > > Build results: > total: 159 pass: 159 fail: 0 > Qemu test results: > total: 343 pass: 343 fail: 0 Wonderful, thanks for testing all of these and letting me know. greg k-h
Re: [PATCH] net: can: Increase tx queue length
Toke Høiland-Jørgensen writes: > Appana Durga Kedareswara Rao writes: > >> Hi Andre, >> >> >>> >>> On 3/9/19 3:07 PM, Appana Durga Kedareswara rao wrote: >>> > While stress testing the CAN interface on xilinx axi can in loopback >>> > mode getting message "write: no buffer space available" >>> > Increasing device tx queue length resolved the above mentioned issue. >>> >>> No need to patch the kernel: >>> >>> $ ip link set txqueuelen 500 >>> >>> does the same thing. >> >> Thanks for the review... >> Agree but it is not an out of box solution right?? >> Do you have any idea for socket can devices why the tx queue length is 10 >> whereas >> for other network devices (ex: ethernet) it is 1000 ?? > > Probably because you don't generally want a long queue adding latency on > a CAN interface? The default 1000 is already way too much even for an > Ethernet device in a lot of cases. > > If you get "out of buffer" errors it means your application is sending > things faster than the receiver (or device) can handle them. If you > solve this by increasing the queue length you are just papering over the > underlying issue, and trading latency for fewer errors. This tradeoff > *may* be appropriate for your particular application, but I can imagine > it would not be appropriate as a default. Keeping the buffer size small > allows errors to propagate up to the application, which can then back > off, or do something smarter, as appropriate. > > I don't know anything about the actual discussions going on when the > defaults were set, but I can imagine something along the lines of the > above was probably a part of it :) > > -Toke In a related discussion, loud and often difficult, over here on the can bus, https://github.com/systemd/systemd/issues/9194#issuecomment-469403685 we found that applying fq_codel as the default via sysctl qdisc a bad idea for systems for at least one model of can device. If you scroll back on the bug, a good description of what the can subsystem expects from the qdisc is therein - it mandates an in-order fifo qdisc or no queue at all. the CAN protocol expects each packet to be transmitted successfully or rejected, and if so, passes the error up to userspace and is supposed to stop for further input. As this was the first serious bug ever reported against using fq_codel as the default in 5+ years of systemd and 7 of openwrt deployment I've been taking it very seriously. It's worse than just systemd - openwrt patches out pfifo_fast entirely. pfifo_fast is the wrong qdisc - the right choices are noqueue and possibly pfifo. However, the vcan device exposes noqueue, and so far it has been only the one device ( a 8Devices socketcan USB2CAN ) that did not do this in their driver that was misbehaving. Which was just corrected with a simple: static int usb_8dev_probe(struct usb_interface *intf, const struct usb_device_id *id) { ... netdev->netdev_ops = _8dev_netdev_ops; netdev->flags |= IFF_ECHO; /* we support local echo */ +netdev->priv_flags |= IFF_NO_QUEUE; ... } and successfully tested on that bug report. So at the moment, my thought is that all can devices should default to noqueue, if they are not already. I think a pfifo_fast and a qlen of any size is the wrong thing, but I still don't know enough about what other can devices do or did to be certain.
Re: [PATCH] xfs: Use kmem_zalloc for bp->b_pages.
On Sat, Mar 09, 2019 at 09:32:30AM -0800, Darrick J. Wong wrote: > On Sat, Mar 09, 2019 at 11:36:36PM +0800, Sean Fu wrote: > > Change the allocation of bp->b_pages to use kmem_zalloc instead of > > kmem_alloc. > > Remove unnecessary memset for bp->b_pages. > > > > This reduces text size by 42 bytes. > > Before: > >textdata bss dec hex filename > > 23335 588 8 239315d7b ./fs/xfs/xfs_buf.o > > After: > >textdata bss dec hex filename > > 23293 588 8 238895d51 ./fs/xfs/xfs_buf.o > > > > Signed-off-by: Sean Fu > > --- > > fs/xfs/xfs_buf.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c > > index 4f5f2ff3f70f..be4f740b97c1 100644 > > --- a/fs/xfs/xfs_buf.c > > +++ b/fs/xfs/xfs_buf.c > > @@ -289,12 +289,11 @@ _xfs_buf_get_pages( > > if (page_count <= XB_PAGES) { > > bp->b_pages = bp->b_page_array; > > } else { > > - bp->b_pages = kmem_alloc(sizeof(struct page *) * > > + bp->b_pages = kmem_zalloc(sizeof(struct page *) * > > page_count, KM_NOFS); > > if (bp->b_pages == NULL) > > return -ENOMEM; > > } > > - memset(bp->b_pages, 0, sizeof(struct page *) * page_count); > > Does this leave b_pages uninitialized in the page_count <= XB_PAGES > case? bp is allocated by kmem_zone_zalloc, But i will take a deep look at xfs_buf_associate_memory. > > --D > > > } > > return 0; > > } > > -- > > 2.16.4 > >
Re: Nokia N900: wl1251 spi3.0: EOW timed out on
Hi. On 10-Mar-19 6:23 AM, Merlijn Wajer wrote: > > Hi, > > On 10/03/2019 00:22, Merlijn Wajer wrote: >> Hi, >> >> I just migrated to Linux 5.0 (from 4.15) on my Nokia N900, and I'm >> getting a lot of messages like this: >> >>> wl1251 spi3.0: EOW timed out Could you try if this patch fixes the issue? This is part of latest mainline tree but not part of 5.0: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=baf8b9f8d260c55a86405f70a384c29cda888476 Regards Vignesh >> >> and it ends with: >> >>> [ 29.072174] wl1251: ERROR chip id doesn't match after firmware boot >> >> My tree carries some patches, but none are related to SPI or wl1251. Any >> clue what might be up? > > Reverting these three commits makes the problem go away: > > commit 89e8b9cb846515e4435eb42df7009b824cf3405a > Author: Vignesh R > Date: Mon Oct 15 12:08:29 2018 +0530 > > spi: omap2-mcspi: Add slave mode support > > > commit b682cffa3ac6d9d9e16e9b413c45caee3b391fab > Author: Vignesh R > Date: Mon Oct 15 12:08:28 2018 +0530 > > spi: omap2-mcspi: Set FIFO DMA trigger level to word length > > > commit 13d515c796adc49a49b0cd2212ccd7f43a37fc5a > Author: Vignesh R > Date: Mon Oct 15 12:08:27 2018 +0530 > > spi: omap2-mcspi: Switch to readl_poll_timeout() > > I reverted 13d515c796adc49a49b0cd2212ccd7f43a37fc5a before, and that > didn't make the difference, so I assume the problematic commit is either > b682cffa3ac6d9d9e16e9b413c45caee3b391fab or > 89e8b9cb846515e4435eb42df7009b824cf3405a > > Cheers, > Merlijn > >> dmesg attached. >> >> Cheers, >> Merlijn >> >> [1] >> >> [0.00] Booting Linux on physical CPU 0x0 >> [0.00] Linux version 5.0.0+ (merlijn@kgpe-d16) (gcc version >> 7.3.0 (Gentoo Hardened 7.3.0-r3 p1.4)) #6 PREEMPT Wed Mar 6 08:35:59 CET >> 2019 >> [0.00] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), >> cr=10c5387d >> [0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing >> instruction cache >> [0.00] OF: fdt: Machine model: Nokia N900 >> [0.00] Memory policy: Data cache writeback >> [0.00] On node 0 totalpages: 65280 >> [0.00] Normal zone: 510 pages used for memmap >> [0.00] Normal zone: 0 pages reserved >> [0.00] Normal zone: 65280 pages, LIFO batch:15 >> [0.00] CPU: All CPU(s) started in SVC mode. >> [0.00] OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp) >> [0.00] random: get_random_bytes called from >> start_kernel+0x80/0x3fc with crng_init=0 >> [0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 >> [0.00] pcpu-alloc: [0] 0 >> [0.00] Built 1 zonelists, mobility grouping on. Total pages: 64770 >> [0.00] Kernel command line: root=/dev/mmcblk0p2 rootwait rw >> mtdoops.mtddev=log console=tty1 omapfb.vram=0:4M >> omapfb.mode=lcd:848x480-16 nokia-modem.pm=1 >> [0.00] Dentry cache hash table entries: 32768 (order: 5, 131072 >> bytes) >> [0.00] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) >> [0.00] Memory: 216140K/261120K available (6144K kernel code, >> 258K rwdata, 1856K rodata, 1024K init, 32920K bss, 44980K reserved, 0K >> cma-reserved, 0K highmem) >> [0.00] Virtual kernel memory layout: >>vector : 0x - 0x1000 ( 4 kB) >>fixmap : 0xffc0 - 0xfff0 (3072 kB) >>vmalloc : 0xd000 - 0xff80 ( 760 MB) >>lowmem : 0xc000 - 0xcff0 ( 255 MB) >>pkmap : 0xbfe0 - 0xc000 ( 2 MB) >>modules : 0xbf00 - 0xbfe0 ( 14 MB) >> .text : 0x(ptrval) - 0x(ptrval) (7136 kB) >> .init : 0x(ptrval) - 0x(ptrval) (1024 kB) >> .data : 0x(ptrval) - 0x(ptrval) ( 259 kB) >> .bss : 0x(ptrval) - 0x(ptrval) (32921 kB) >> [0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 >> [0.00] rcu: Preemptible hierarchical RCU implementation. >> [0.00] Tasks RCU enabled. >> [0.00] rcu: RCU calculated value of scheduler-enlistment delay >> is 10 jiffies. >> [0.00] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 >> [0.00] IRQ: Found an INTC at 0x(ptrval) (revision 4.0) with 96 >> interrupts >> [0.00] Clocking rate (Crystal/Core/MPU): 19.2/332/500 MHz >> [0.00] OMAP clockevent source: timer1 at 32768 Hz >> [0.00] clocksource: 32k_counter: mask: 0x max_cycles: >> 0x, max_idle_ns: 58327039986419 ns >> [0.30] sched_clock: 32 bits at 32kHz, resolution 30517ns, wraps >> every 6553584741ns >> [0.30] OMAP clocksource: 32k_counter at 32768 Hz >> [0.000579] Console: colour dummy device 80x30 >> [0.001647] printk: console [tty1] enabled >> [0.001708] Calibrating delay loop... 496.43 BogoMIPS (lpj=2482176) >> [
[PULL] virtio,vhost: cleanups and fixes
The following changes since commit 1c163f4c7b3f621efff9b28a47abb36f7378d783: Linux 5.0 (2019-03-03 15:21:29 -0800) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git tags/for_linus for you to fetch changes up to cfdbb4ed31aa777d59b288810f66eb06249ee5b7: vhost: silence an unused-variable warning (2019-03-06 11:32:37 -0500) virtio: fixes, cleanups Several fixes, most notably fix for virtio on swiotlb systems. Signed-off-by: Michael S. Tsirkin Arnd Bergmann (1): vhost: silence an unused-variable warning Cornelia Huck (3): virtio-ccw: diag 500 may return a negative cookie virtio-ccw: wire up ->bus_name callback virtio: hint if callbacks surprisingly might sleep Halil Pasic (1): s390/virtio: handle find on invalid queue gracefully Joerg Roedel (5): swiotlb: Introduce swiotlb_max_mapping_size() swiotlb: Add is_swiotlb_active() function dma: Introduce dma_max_mapping_size() virtio: Introduce virtio_max_dma_size() virtio-blk: Consider virtio_max_dma_size() for maximum segment size Wei Wang (2): virtio-balloon: improve update_balloon_size_func virtio_balloon: remove the unnecessary 0-initialization Documentation/DMA-API.txt | 8 Documentation/virtual/kvm/s390-diag.txt | 3 ++- drivers/block/virtio_blk.c | 10 ++ drivers/s390/virtio/virtio_ccw.c| 12 +++- drivers/vhost/vhost.c | 2 +- drivers/virtio/virtio.c | 2 ++ drivers/virtio/virtio_balloon.c | 6 -- drivers/virtio/virtio_ring.c| 11 +++ include/linux/dma-mapping.h | 8 include/linux/swiotlb.h | 11 +++ include/linux/virtio.h | 2 ++ include/linux/virtio_config.h | 13 + kernel/dma/direct.c | 11 +++ kernel/dma/mapping.c| 14 ++ kernel/dma/swiotlb.c| 14 ++ 15 files changed, 118 insertions(+), 9 deletions(-)
Re: [PATCH 4/4] iommu/vt-d: Remove lazy allocation of domains
Hi, On 3/9/19 7:49 PM, James Sewart wrote: Hey Lu, On 9 Mar 2019, at 01:53, Lu Baolu wrote: Hi James, On 3/9/19 12:57 AM, James Sewart wrote: Hey Lu, On 8 Mar 2019, at 03:09, Lu Baolu wrote: Do you mind if I work on top of your patches for further cleanups and sign off a v2 together with you? Sure, sounds good. I’ll fixup patch 3 and have a go at integrating iommu_prepare_isa into get_resv_regions. This should make the initial domain logic here quite concise. Here attached three extra patches which I think should be added before PATCH 3/4, and some further cleanup changes which you can merge with PATCH 4/4. 0006-iommu-Add-ops-entry-for-vendor-specific-default-doma.patch 0007-iommu-vt-d-Add-is_identity_map-ops-entry.patch These two patches aim to add a generic method for vendor specific iommu drivers to specify the type of the default domain for a device. Intel iommu driver will register an ops for this since it already has its own identity map adjudicator for a long time. This seems like a good idea, but as domain alloc is only called for the default domain on first device attached to a group, we may miss checking whether a device added later should have an identity domain. Should there be paths to downgrade a groups domain if one of the devices requires one? Good catch! This is supposed to be handled in iommu_no_mapping(). But, obviously current code sticks to lazy domain allocation. I'm not sure whether there are any real such cases, but we should handle it in a clean way. My idea is that we could downgrade to multiple domains per group (just like what we have now) in this case and print a kernel message for this. I think if a device requires an identity domain, then it should ignore attempts to attach to something else. A print to warn a user about this would be a good idea. I figure during attach: if iommu_no_mapping() then attach to si_domain and print, else continue with the given domain. Yes, agree. Best regards, Lu Baolu
[git pull] Input updates for v5.1-rc0
Hi Linus, Please pull from: git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git for-linus to receive updates for the input subsystem. You will get: - update to ili210x touchscreen driver, refreshing the code and adding support for ILI251X line - update to st1232 touchscreen driver adding support for st1633 model - sx8654 touchscreen driver gained support for sx8650 model - edt-ft5x06 touchscreen driver gained support for Evervision FT5726 - Goodix touchscreen driver can now support gt5688 - new vibrator driver for MSM SOCs - miscellaneous fixes for the rest of input drivers Thanks! Changelog: - Aditya Pakki (1): Input: ad7879 - add check for read errors in interrupt Arnd Bergmann (2): Input: msm-vibrator - use correct gpio header Input: raspberrypi-ts - select CONFIG_INPUT_POLLDEV Brian Masney (1): Input: add new vibrator driver for various MSM SOCs Dan Carpenter (1): Input: msm-vibrator - tweak an error message Dmitry Torokhov (5): Input: sx8654 - do not override interrupt trigger Input: ili210x - switch to using devm_device_add_group() Input: stmfts - acknowledge that setting brightness is a blocking call Input: tm2-touchkey - acknowledge that setting brightness is a blocking call Input: ims-pcu - switch to using brightness_set_blocking() Florian Fainelli (1): Input: gpio-keys - add shutdown callback Guido Günther (3): Input: goodix - support Goodix gt5688 Input: goodix - refer to touchscreen.txt in device tree bindings Input: goodix - print values in case of inconsistencies Gustavo A. R. Silva (3): Input: tca6416-keypad - use struct_size() in kzalloc() Input: mcs_touchkey - use struct_size() in kzalloc() Input: db9 - mark expected switch fall-through Hans de Goede (2): Input: soc_button_array - add usage-page 0x01 usage-id 0xca mapping Input: soc_button_array - fix mapping of the 5th GPIO in a PNP0C40 device Jason Gerecke (1): Input: wacom_serial4 - add support for Wacom ArtPad II tablet Jonathan Bakker (3): Input: tm2-touchkey - correct initial brightness Input: tm2-touchkey - allow specifying custom keycodes Input: tm2-touchkey - add support for aries touchkey variant Marco Felsch (3): Input: edt-ft5x06 - add support for Evervision FT5726 Input: edt-ft5x06 - add support to update ev-ft5726 registers Input: edt-ft5x06 - add offset support for ev-ft5726 Marek Vasut (11): Input: ili210x - add DT binding document Input: ili210x - drop platform data support Input: ili210x - drop get_pendown_state Input: ili210x - convert to devm_ functions Input: ili210x - add reset GPIO support Input: ili210x - convert to devm IRQ Input: ili210x - rework the touchscreen sample processing Input: ili210x - reorder probe Input: ili210x - add OF match table Input: ili210x - add ILI251X support Input: ili210x - fetch touchscreen geometry from DT Martin Kepplinger (3): Input: st1232 - add support for st1633 Input: st1232 - add Martin as module author Input: st1232 - switch to gpiod API Matthias Fend (1): Input: st1232 - handle common DT bindings Richard Leitner (5): Input: sx8654 - add reset-gpio support Input: sx8654 - add sx8655 and sx8656 to compatibles Input: sx8654 - add sx8650 support Input: sx8654 - use common of_touchscreen functions Input: sx8654 - convert #defined flags to BIT(x) Rob Herring (1): Input: i8042 - rework DT node name comparisons Simon Shields (1): Input: tm2-touchkey - add support for midas touchkey Sven Van Asbroeck (2): Input: qt2160 - remove redundant spinlock Input: synaptics_i2c - remove redundant spinlock Vincent Batts (1): Input: elan_i2c - add id for touchpad found in Lenovo s21e-20 YueHaibing (2): Input: mtk-pmic-keys - remove duplicated include from mtk-pmic-keys.c Input: ti_am335x_tsc - remove set but not used variable 'tscadc_dev' Diffstat: .../bindings/input/cypress,tm2-touchkey.txt| 9 +- .../devicetree/bindings/input/ilitek,ili2xxx.txt | 25 ++ .../devicetree/bindings/input/msm-vibrator.txt | 36 +++ .../bindings/input/touchscreen/edt-ft5x06.txt | 13 +- .../bindings/input/touchscreen/goodix.txt | 14 +- .../bindings/input/touchscreen/sitronix-st1232.txt | 8 +- .../bindings/input/touchscreen/sx8654.txt | 10 +- drivers/input/joystick/db9.c | 2 +- drivers/input/keyboard/gpio_keys.c | 10 + drivers/input/keyboard/mcs_touchkey.c | 5 +- drivers/input/keyboard/mtk-pmic-keys.c | 13 +- drivers/input/keyboard/qt2160.c| 9 - drivers/input/keyboard/tca6416-keypad.c| 4 +- drivers/input/keyboard/tm2-touchkey.c | 136 ++--- drivers/input/misc/Kconfig
Re: [PATCH v3] blkcg: prevent priority inversion problem during sync()
Hi Andrea, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.0 next-20190306] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Andrea-Righi/blkcg-prevent-priority-inversion-problem-during-sync/20190310-020543 config: i386-randconfig-s1-201910 (attached as .config) compiler: gcc-6 (Debian 6.5.0-2) 6.5.0 20181026 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): fs/fs-writeback.c: In function 'sync_inodes_sb': >> fs/fs-writeback.c:2450:2: error: implicit declaration of function >> 'blkcg_start_wb_wait_on_bdi' [-Werror=implicit-function-declaration] blkcg_start_wb_wait_on_bdi(bdi); ^~ >> fs/fs-writeback.c:2460:2: error: implicit declaration of function >> 'blkcg_stop_wb_wait_on_bdi' [-Werror=implicit-function-declaration] blkcg_stop_wb_wait_on_bdi(bdi); ^ cc1: some warnings being treated as errors vim +/blkcg_start_wb_wait_on_bdi +2450 fs/fs-writeback.c 2419 2420 /** 2421 * sync_inodes_sb - sync sb inode pages 2422 * @sb: the superblock 2423 * 2424 * This function writes and waits on any dirty inode belonging to this 2425 * super_block. 2426 */ 2427 void sync_inodes_sb(struct super_block *sb) 2428 { 2429 DEFINE_WB_COMPLETION_ONSTACK(done); 2430 struct wb_writeback_work work = { 2431 .sb = sb, 2432 .sync_mode = WB_SYNC_ALL, 2433 .nr_pages = LONG_MAX, 2434 .range_cyclic = 0, 2435 .done = , 2436 .reason = WB_REASON_SYNC, 2437 .for_sync = 1, 2438 }; 2439 struct backing_dev_info *bdi = sb->s_bdi; 2440 2441 /* 2442 * Can't skip on !bdi_has_dirty() because we should wait for !dirty 2443 * inodes under writeback and I_DIRTY_TIME inodes ignored by 2444 * bdi_has_dirty() need to be written out too. 2445 */ 2446 if (bdi == _backing_dev_info) 2447 return; 2448 WARN_ON(!rwsem_is_locked(>s_umount)); 2449 > 2450 blkcg_start_wb_wait_on_bdi(bdi); 2451 2452 /* protect against inode wb switch, see inode_switch_wbs_work_fn() */ 2453 bdi_down_write_wb_switch_rwsem(bdi); 2454 bdi_split_work_to_wbs(bdi, , false); 2455 wb_wait_for_completion(bdi, ); 2456 bdi_up_write_wb_switch_rwsem(bdi); 2457 2458 wait_sb_inodes(sb); 2459 > 2460 blkcg_stop_wb_wait_on_bdi(bdi); 2461 } 2462 EXPORT_SYMBOL(sync_inodes_sb); 2463 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [GIT PULL] first round of SCSI updates for the 5.0+ merge window
The pull request you sent on Wed, 06 Mar 2019 22:29:46 -0800: > git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-misc has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/92fff53b7191cae566be9ca6752069426c7f8241 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] Please pull RDMA subsystem changes
The pull request you sent on Thu, 7 Mar 2019 01:34:16 +: > git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git tags/for-linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/a50243b1ddcdd766d0d17fbfeeb1a22e62fdc461 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
DRM-based Oops viewer
Hello DRM/UEFI maintainers, Several years ago, I wrote a set of patches to dump the kernel log to disk upon panic -- through BIOS INT 0x13 services. [1] The overwhelming response was that it's unsafe to do this in a generic manner. Linus proposed a video-based viewer instead: [2] If you want to do the BIOS services thing, do it for video: copy the oops to low RAM, return to real mode, re-run the graphics card POST routines to initialize text-mode, and use the BIOS to print out the oops. That is WAY less scary than writing to disk. Of course it's 2019 now though, and it's quite known that Intel is officially obsoleting the PC/AT BIOS by 2020.. [3] Researching whether this can be done from UEFI, it was also clear that UEFI "Runtime Services" do not provide any re-initialization routines. [4] The maximum possible that UEFI can provide is a GOP-provided framebuffer that's ready to use by the OS -- even after the UEFI boot phase is marked as done through ExitBootServices(). [5] Of course, once native drivers like i915 or radeon take over, such a framebuffer is toast... [6] Thus a possible remaining option, is to display the oops through "minimal" DRM drivers provided for each HW variant... Since these special drivers will run only and fully under a panic() context though, several constraints exist: - The code should be fully synchronous (irqs are disabled) - It should not allocate any dynamic memory - It should make minimal assumptions about HW state - It should not chain into any other kernel subsystem - It has ample freedom to use delay-based loops and the like, the kernel is already dead. How feasible is it to have such a special "DRM viewoops" framework + its minimal drivers in the kernel? The target is to start from i915, since that's what in my laptop now, and work from there.. Some final notes: - The NT kernel has a similar concept, but for storage instead. They're used to dump core under kernel panic() situations, and are called "Minoport storage drivers". [7] - Since Windows 7+, a very fancy Blue Screen of Death is displayed, with Unicode and whatnot, implying GPU drivers involvement. [8] - Mac OS X also does something similar [9] - On Linux laptops, the current situation is _really_ bad. In any graphical session, type "echo c > /proc/sysrq-trigger"; the screen will just completely freeze... Desired first goal: just print the panic() log Thanks a lot, [1] https://lore.kernel.org/lkml/20110125134748.GA10051@laptop [2] https://lore.kernel.org/lkml/AANLkTinU0KYiCd4p=z+=ojbkeeot2g+cayvdru02k...@mail.gmail.com [3] https://uefi.org/sites/default/files/resources/Brian_Richardson_Intel_Final.pdf [4] UEFI v2.7 spec, Chapter 8, "Services — Runtime Services" [5] UEFI v2.7 spec, Section 12.9, "Graphics Output Protocol" "The Graphics Output Protocol supports this capability by providing the EFI OS loader access to a hardware frame buffer and enough information to allow the OS to draw directly to the graphics output device." [6] linux/drivers/gpu/drm/i915/i915_drv.c::i915_kick_out_firmware_fb() linux/drivers/gpu/drm/radeon/radeon_drv.c::radeon_pci_probe() [7] https://docs.microsoft.com/en-us/windows-hardware/drivers/storage/restrictions-on-miniport-drivers-that-manage-the-boot-drive [8] https://upload.wikimedia.org/wikipedia/commons/archive/5/56/20181019151937%21Bsodwindows10.png [9] https://upload.wikimedia.org/wikipedia/commons/4/4a/Mac_OS_X_10.2_Kernel_Panic.jpg --darwi http://darwish.chasingpointers.com
[PATCH v3 3/3] arm64: mm: enable per pmd page table lock
Switch from per mm_struct to per pmd page table lock by enabling ARCH_ENABLE_SPLIT_PMD_PTLOCK. This provides better granularity for large system. I'm not sure if there is contention on mm->page_table_lock. Given the option comes at no cost (apart from initializing more spin locks), why not enable it now. We only do so when pmd is not folded, so we don't mistakenly call pgtable_pmd_page_ctor() on pud or p4d in pgd_pgtable_alloc(). (We check shift against PMD_SHIFT, which is same as PUD_SHIFT when pmd is folded). Signed-off-by: Yu Zhao --- arch/arm64/Kconfig | 3 +++ arch/arm64/include/asm/pgalloc.h | 12 +++- arch/arm64/include/asm/tlb.h | 5 - 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index cfbf307d6dc4..a3b1b789f766 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -872,6 +872,9 @@ config ARCH_WANT_HUGE_PMD_SHARE config ARCH_HAS_CACHE_LINE_SIZE def_bool y +config ARCH_ENABLE_SPLIT_PMD_PTLOCK + def_bool y if PGTABLE_LEVELS > 2 + config SECCOMP bool "Enable seccomp to safely compute untrusted bytecode" ---help--- diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h index 52fa47c73bf0..dabba4b2c61f 100644 --- a/arch/arm64/include/asm/pgalloc.h +++ b/arch/arm64/include/asm/pgalloc.h @@ -33,12 +33,22 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr) { - return (pmd_t *)__get_free_page(PGALLOC_GFP); + struct page *page; + + page = alloc_page(PGALLOC_GFP); + if (!page) + return NULL; + if (!pgtable_pmd_page_ctor(page)) { + __free_page(page); + return NULL; + } + return page_address(page); } static inline void pmd_free(struct mm_struct *mm, pmd_t *pmdp) { BUG_ON((unsigned long)pmdp & (PAGE_SIZE-1)); + pgtable_pmd_page_dtor(virt_to_page(pmdp)); free_page((unsigned long)pmdp); } diff --git a/arch/arm64/include/asm/tlb.h b/arch/arm64/include/asm/tlb.h index 106fdc951b6e..4e3becfed387 100644 --- a/arch/arm64/include/asm/tlb.h +++ b/arch/arm64/include/asm/tlb.h @@ -62,7 +62,10 @@ static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pte, static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmdp, unsigned long addr) { - tlb_remove_table(tlb, virt_to_page(pmdp)); + struct page *page = virt_to_page(pmdp); + + pgtable_pmd_page_dtor(page); + tlb_remove_table(tlb, page); } #endif -- 2.21.0.360.g471c308f928-goog
[PATCH v3 1/3] arm64: mm: use appropriate ctors for page tables
For pte page, use pgtable_page_ctor(); for pmd page, use pgtable_pmd_page_ctor(); and for the rest (pud, p4d and pgd), don't use any. For now, we don't select ARCH_ENABLE_SPLIT_PMD_PTLOCK and pgtable_pmd_page_ctor() is a nop. When we do in patch 3, we make sure pmd is not folded so we won't mistakenly call pgtable_pmd_page_ctor() on pud or p4d. Acked-by: Mark Rutland Signed-off-by: Yu Zhao --- arch/arm64/mm/mmu.c | 36 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index b6f5aa52ac67..f704b291f2c5 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -98,7 +98,7 @@ pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, } EXPORT_SYMBOL(phys_mem_access_prot); -static phys_addr_t __init early_pgtable_alloc(void) +static phys_addr_t __init early_pgtable_alloc(int shift) { phys_addr_t phys; void *ptr; @@ -173,7 +173,7 @@ static void init_pte(pmd_t *pmdp, unsigned long addr, unsigned long end, static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr, unsigned long end, phys_addr_t phys, pgprot_t prot, - phys_addr_t (*pgtable_alloc)(void), + phys_addr_t (*pgtable_alloc)(int), int flags) { unsigned long next; @@ -183,7 +183,7 @@ static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr, if (pmd_none(pmd)) { phys_addr_t pte_phys; BUG_ON(!pgtable_alloc); - pte_phys = pgtable_alloc(); + pte_phys = pgtable_alloc(PAGE_SHIFT); __pmd_populate(pmdp, pte_phys, PMD_TYPE_TABLE); pmd = READ_ONCE(*pmdp); } @@ -207,7 +207,7 @@ static void alloc_init_cont_pte(pmd_t *pmdp, unsigned long addr, static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end, phys_addr_t phys, pgprot_t prot, -phys_addr_t (*pgtable_alloc)(void), int flags) +phys_addr_t (*pgtable_alloc)(int), int flags) { unsigned long next; pmd_t *pmdp; @@ -245,7 +245,7 @@ static void init_pmd(pud_t *pudp, unsigned long addr, unsigned long end, static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr, unsigned long end, phys_addr_t phys, pgprot_t prot, - phys_addr_t (*pgtable_alloc)(void), int flags) + phys_addr_t (*pgtable_alloc)(int), int flags) { unsigned long next; pud_t pud = READ_ONCE(*pudp); @@ -257,7 +257,7 @@ static void alloc_init_cont_pmd(pud_t *pudp, unsigned long addr, if (pud_none(pud)) { phys_addr_t pmd_phys; BUG_ON(!pgtable_alloc); - pmd_phys = pgtable_alloc(); + pmd_phys = pgtable_alloc(PMD_SHIFT); __pud_populate(pudp, pmd_phys, PUD_TYPE_TABLE); pud = READ_ONCE(*pudp); } @@ -293,7 +293,7 @@ static inline bool use_1G_block(unsigned long addr, unsigned long next, static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, phys_addr_t phys, pgprot_t prot, - phys_addr_t (*pgtable_alloc)(void), + phys_addr_t (*pgtable_alloc)(int), int flags) { unsigned long next; @@ -303,7 +303,7 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, if (pgd_none(pgd)) { phys_addr_t pud_phys; BUG_ON(!pgtable_alloc); - pud_phys = pgtable_alloc(); + pud_phys = pgtable_alloc(PUD_SHIFT); __pgd_populate(pgdp, pud_phys, PUD_TYPE_TABLE); pgd = READ_ONCE(*pgdp); } @@ -344,7 +344,7 @@ static void alloc_init_pud(pgd_t *pgdp, unsigned long addr, unsigned long end, static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, unsigned long virt, phys_addr_t size, pgprot_t prot, -phys_addr_t (*pgtable_alloc)(void), +phys_addr_t (*pgtable_alloc)(int), int flags) { unsigned long addr, length, end, next; @@ -370,11 +370,23 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, } while (pgdp++, addr = next, addr != end); } -static phys_addr_t pgd_pgtable_alloc(void) +static phys_addr_t pgd_pgtable_alloc(int shift) { void *ptr = (void *)__get_free_page(PGALLOC_GFP); - if (!ptr || !pgtable_page_ctor(virt_to_page(ptr))) - BUG(); + BUG_ON(!ptr); + + /* +* Call proper page table ctor in case later we need to +
[PATCH v3 2/3] arm64: mm: don't call page table ctors for init_mm
init_mm doesn't require page table lock to be initialized at any level. Add a separate page table allocator for it, and the new one skips page table ctors. The ctors allocate memory when ALLOC_SPLIT_PTLOCKS is set. Not calling them avoids memory leak in case we call pte_free_kernel() on init_mm. Acked-by: Mark Rutland Signed-off-by: Yu Zhao --- arch/arm64/mm/mmu.c | 15 +-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index f704b291f2c5..d1dc2a2777aa 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -370,6 +370,16 @@ static void __create_pgd_mapping(pgd_t *pgdir, phys_addr_t phys, } while (pgdp++, addr = next, addr != end); } +static phys_addr_t pgd_kernel_pgtable_alloc(int shift) +{ + void *ptr = (void *)__get_free_page(PGALLOC_GFP); + BUG_ON(!ptr); + + /* Ensure the zeroed page is visible to the page table walker */ + dsb(ishst); + return __pa(ptr); +} + static phys_addr_t pgd_pgtable_alloc(int shift) { void *ptr = (void *)__get_free_page(PGALLOC_GFP); @@ -594,7 +604,7 @@ static int __init map_entry_trampoline(void) /* Map only the text into the trampoline page table */ memset(tramp_pg_dir, 0, PGD_SIZE); __create_pgd_mapping(tramp_pg_dir, pa_start, TRAMP_VALIAS, PAGE_SIZE, -prot, pgd_pgtable_alloc, 0); +prot, pgd_kernel_pgtable_alloc, 0); /* Map both the text and data into the kernel page table */ __set_fixmap(FIX_ENTRY_TRAMP_TEXT, pa_start, prot); @@ -1070,7 +1080,8 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS; __create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start), -size, PAGE_KERNEL, pgd_pgtable_alloc, flags); +size, PAGE_KERNEL, pgd_kernel_pgtable_alloc, +flags); return __add_pages(nid, start >> PAGE_SHIFT, size >> PAGE_SHIFT, altmap, want_memblock); -- 2.21.0.360.g471c308f928-goog
Re: Nokia N900: wl1251 spi3.0: EOW timed out on
Hi, On 10/03/2019 00:22, Merlijn Wajer wrote: > Hi, > > I just migrated to Linux 5.0 (from 4.15) on my Nokia N900, and I'm > getting a lot of messages like this: > >> wl1251 spi3.0: EOW timed out > > and it ends with: > >> [ 29.072174] wl1251: ERROR chip id doesn't match after firmware boot > > My tree carries some patches, but none are related to SPI or wl1251. Any > clue what might be up? Reverting these three commits makes the problem go away: commit 89e8b9cb846515e4435eb42df7009b824cf3405a Author: Vignesh R Date: Mon Oct 15 12:08:29 2018 +0530 spi: omap2-mcspi: Add slave mode support commit b682cffa3ac6d9d9e16e9b413c45caee3b391fab Author: Vignesh R Date: Mon Oct 15 12:08:28 2018 +0530 spi: omap2-mcspi: Set FIFO DMA trigger level to word length commit 13d515c796adc49a49b0cd2212ccd7f43a37fc5a Author: Vignesh R Date: Mon Oct 15 12:08:27 2018 +0530 spi: omap2-mcspi: Switch to readl_poll_timeout() I reverted 13d515c796adc49a49b0cd2212ccd7f43a37fc5a before, and that didn't make the difference, so I assume the problematic commit is either b682cffa3ac6d9d9e16e9b413c45caee3b391fab or 89e8b9cb846515e4435eb42df7009b824cf3405a Cheers, Merlijn > dmesg attached. > > Cheers, > Merlijn > > [1] > > [0.00] Booting Linux on physical CPU 0x0 > [0.00] Linux version 5.0.0+ (merlijn@kgpe-d16) (gcc version > 7.3.0 (Gentoo Hardened 7.3.0-r3 p1.4)) #6 PREEMPT Wed Mar 6 08:35:59 CET > 2019 > [0.00] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), > cr=10c5387d > [0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing > instruction cache > [0.00] OF: fdt: Machine model: Nokia N900 > [0.00] Memory policy: Data cache writeback > [0.00] On node 0 totalpages: 65280 > [0.00] Normal zone: 510 pages used for memmap > [0.00] Normal zone: 0 pages reserved > [0.00] Normal zone: 65280 pages, LIFO batch:15 > [0.00] CPU: All CPU(s) started in SVC mode. > [0.00] OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp) > [0.00] random: get_random_bytes called from > start_kernel+0x80/0x3fc with crng_init=0 > [0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 > [0.00] pcpu-alloc: [0] 0 > [0.00] Built 1 zonelists, mobility grouping on. Total pages: 64770 > [0.00] Kernel command line: root=/dev/mmcblk0p2 rootwait rw > mtdoops.mtddev=log console=tty1 omapfb.vram=0:4M > omapfb.mode=lcd:848x480-16 nokia-modem.pm=1 > [0.00] Dentry cache hash table entries: 32768 (order: 5, 131072 > bytes) > [0.00] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) > [0.00] Memory: 216140K/261120K available (6144K kernel code, > 258K rwdata, 1856K rodata, 1024K init, 32920K bss, 44980K reserved, 0K > cma-reserved, 0K highmem) > [0.00] Virtual kernel memory layout: >vector : 0x - 0x1000 ( 4 kB) >fixmap : 0xffc0 - 0xfff0 (3072 kB) >vmalloc : 0xd000 - 0xff80 ( 760 MB) >lowmem : 0xc000 - 0xcff0 ( 255 MB) >pkmap : 0xbfe0 - 0xc000 ( 2 MB) >modules : 0xbf00 - 0xbfe0 ( 14 MB) > .text : 0x(ptrval) - 0x(ptrval) (7136 kB) > .init : 0x(ptrval) - 0x(ptrval) (1024 kB) > .data : 0x(ptrval) - 0x(ptrval) ( 259 kB) > .bss : 0x(ptrval) - 0x(ptrval) (32921 kB) > [0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 > [0.00] rcu: Preemptible hierarchical RCU implementation. > [0.00] Tasks RCU enabled. > [0.00] rcu: RCU calculated value of scheduler-enlistment delay > is 10 jiffies. > [0.00] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 > [0.00] IRQ: Found an INTC at 0x(ptrval) (revision 4.0) with 96 > interrupts > [0.00] Clocking rate (Crystal/Core/MPU): 19.2/332/500 MHz > [0.00] OMAP clockevent source: timer1 at 32768 Hz > [0.00] clocksource: 32k_counter: mask: 0x max_cycles: > 0x, max_idle_ns: 58327039986419 ns > [0.30] sched_clock: 32 bits at 32kHz, resolution 30517ns, wraps > every 6553584741ns > [0.30] OMAP clocksource: 32k_counter at 32768 Hz > [0.000579] Console: colour dummy device 80x30 > [0.001647] printk: console [tty1] enabled > [0.001708] Calibrating delay loop... 496.43 BogoMIPS (lpj=2482176) > [0.048919] pid_max: default: 32768 minimum: 301 > [0.049133] LSM: Security Framework initializing > [0.049255] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) > [0.049316] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 > bytes) > [0.050628] CPU: Testing write buffer coherency: ok > [0.050750] CPU0: Spectre v2: using BPIALL workaround > [0.052307] Setting up static identity map for
Re: [PATCH] Input: fix oops in input_to_handler
Hi Zhipeng, On Fri, Mar 01, 2019 at 12:13:27PM +0800, Zhipeng Xie wrote: > we got the following boot crash: > > [ 36.086344] Internal error: Oops: 9604 [#1] SMP > [ 36.091371] CPU: 32 PID: 0 Comm: swapper/32 Tainted: G OE >4.19.25-vhulk1901.1.0.h111.aarch64 #1 > [ 36.101444] Hardware name: Huawei TaiShan 2280 /BC11SPCD, BIOS 1.58 > 10/24/2018 > [ 36.108860] pstate: 2085 (nzCv daIf -PAN -UAO) > [ 36.113727] pc : input_to_handler+0x2c/0x148 > [ 36.118058] lr : input_pass_values.part.2+0x148/0x168 > [ 36.123177] sp : 000100103ba0 > [ 36.126535] x29: 000100103ba0 x28: 801fb2ac5958 > [ 36.131924] x27: 09799000 x26: 0001 > [ 36.137375] x25: x24: 801fb5b57c00 > [ 36.142822] x23: 00020987f3d0 x22: 801faf427e00 > [ 36.148211] x21: 0003 x20: 0003 > [ 36.153599] x19: 801faf427e00 x18: 000e > [ 36.158986] x17: 000e x16: 0007 > [ 36.164374] x15: 0001 x14: 0019 > [ 36.169762] x13: 0033 x12: 004c > [ 36.175150] x11: 0068 x10: 08dfa290 > [ 36.180538] x9 : 007d x8 : > [ 36.185925] x7 : 0053 x6 : > [ 36.191313] x5 : x4 : > [ 36.196700] x3 : 0010 x2 : 0003 > [ 36.202088] x1 : 801fb5b57c00 x0 : 08a120a0 > [ 36.207477] Process swapper/32 (pid: 0, stack limit = > 0x32f86b58) > [ 36.214361] Call trace: > [ 36.216840] input_to_handler+0x2c/0x148 > [ 36.220816] input_pass_values.part.2+0x148/0x168 > [ 36.225582] input_handle_event+0x130/0x5b8 > [ 36.229823] i6.242013] hid_input_report+0x128/0x1b0 > [ 36.246076] hid_irq_in+0x240/0x298 > [ 36.249613] __usb_hcd_giveback_urb+0x9c/0x130 > [ 36.257460] usb_giveback_urb_bh+0xf4/0x198 > [ 36.265127] tasklet_action_common.isra.6+0x94/0x160 > [ 36.273458] tasklet_hi_action+0x2c/0x38 > [ 36.280597] __do_softirq+0x118/0x314 > [ 36.287494] irq_exit+0xa4/0xe8 > [ 36.293682] __handle_domain_irq+0x6c/0xc0 > [ 36.300783] gic_handle_irq+0x6c/0x170 > [ 36.307296] el1_irq+0xb8/0x140 > [ 36.313283] arch_cpu_idle+0x38/0x1c0 > [ 36.319776] default_idle_call+0x24/0x44 > [ 36.326527] do_idle+0x1ec/0x2d0 > [ 36.332503] cpu_startup_entry+0x28/0x30 > [ 36.339161] secondary_start_kernel+0x194/0x1d8 > > We need to check the input_handler before referencing its members. > > Signed-off-by: Zhipeng Xie > --- > drivers/input/input.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/input/input.c b/drivers/input/input.c > index 3304aaa..b768d14 100644 > --- a/drivers/input/input.c > +++ b/drivers/input/input.c > @@ -100,6 +100,9 @@ static unsigned int input_to_handler(struct input_handle > *handle, > struct input_value *end = vals; > struct input_value *v; > > + if (!handler) > + return 0; No, is not a proper change. That means that someone registered an input handle without setting handler, which is not allowed. Do you have any custom input handlers in your system? Thanks. -- Dmitry
[tip:sched/urgent 1/5] kernel/sched/cpufreq_schedutil.c:346:26: note: in expansion of macro 'min'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/urgent head: ce28d2e53cda890771360d32259495dd6a9c4253 commit: f1212844e9dc3a31d41f99713c5522acf92ff291 [1/5] sched/cpufreq: Fix 32-bit math overflow config: i386-randconfig-s2-201910 (attached as .config) compiler: gcc-6 (Debian 6.5.0-2) 6.5.0 20181026 reproduce: git checkout f1212844e9dc3a31d41f99713c5522acf92ff291 # save the attached .config to linux build tree make ARCH=i386 All warnings (new ones prefixed by >>): In file included from arch/x86/include/asm/percpu.h:45:0, from arch/x86/include/asm/current.h:6, from include/linux/sched.h:12, from kernel/sched/sched.h:5, from kernel/sched/cpufreq_schedutil.c:11: kernel/sched/cpufreq_schedutil.c: In function 'sugov_iowait_boost': include/linux/kernel.h:846:29: warning: comparison of distinct pointer types lacks a cast (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1))) ^ include/linux/kernel.h:860:4: note: in expansion of macro '__typecheck' (__typecheck(x, y) && __no_side_effects(x, y)) ^~~ include/linux/kernel.h:870:24: note: in expansion of macro '__safe_cmp' __builtin_choose_expr(__safe_cmp(x, y), \ ^~ include/linux/kernel.h:879:19: note: in expansion of macro '__careful_cmp' #define min(x, y) __careful_cmp(x, y, <) ^ >> kernel/sched/cpufreq_schedutil.c:346:26: note: in expansion of macro 'min' sg_cpu->iowait_boost = min(sg_cpu->iowait_boost << 1, SCHED_CAPACITY_SCALE); ^~~ vim +/min +346 kernel/sched/cpufreq_schedutil.c 311 312 /** 313 * sugov_iowait_boost() - Updates the IO boost status of a CPU. 314 * @sg_cpu: the sugov data for the CPU to boost 315 * @time: the update time from the caller 316 * @flags: SCHED_CPUFREQ_IOWAIT if the task is waking up after an IO wait 317 * 318 * Each time a task wakes up after an IO operation, the CPU utilization can be 319 * boosted to a certain utilization which doubles at each "frequent and 320 * successive" wakeup from IO, ranging from the utilization of the minimum 321 * OPP to the utilization of the maximum OPP. 322 * To keep doubling, an IO boost has to be requested at least once per tick, 323 * otherwise we restart from the utilization of the minimum OPP. 324 */ 325 static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, 326 unsigned int flags) 327 { 328 bool set_iowait_boost = flags & SCHED_CPUFREQ_IOWAIT; 329 330 /* Reset boost if the CPU appears to have been idle enough */ 331 if (sg_cpu->iowait_boost && 332 sugov_iowait_reset(sg_cpu, time, set_iowait_boost)) 333 return; 334 335 /* Boost only tasks waking up after IO */ 336 if (!set_iowait_boost) 337 return; 338 339 /* Ensure boost doubles only one time at each request */ 340 if (sg_cpu->iowait_boost_pending) 341 return; 342 sg_cpu->iowait_boost_pending = true; 343 344 /* Double the boost at each request */ 345 if (sg_cpu->iowait_boost) { > 346 sg_cpu->iowait_boost = min(sg_cpu->iowait_boost << 1, > SCHED_CAPACITY_SCALE); 347 return; 348 } 349 350 /* First wakeup after IO: start with minimum boost */ 351 sg_cpu->iowait_boost = sg_cpu->min; 352 } 353 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Nokia N900: wl1251 spi3.0: EOW timed out on
Hi, I just migrated to Linux 5.0 (from 4.15) on my Nokia N900, and I'm getting a lot of messages like this: > wl1251 spi3.0: EOW timed out and it ends with: > [ 29.072174] wl1251: ERROR chip id doesn't match after firmware boot My tree carries some patches, but none are related to SPI or wl1251. Any clue what might be up? dmesg attached. Cheers, Merlijn [1] [0.00] Booting Linux on physical CPU 0x0 [0.00] Linux version 5.0.0+ (merlijn@kgpe-d16) (gcc version 7.3.0 (Gentoo Hardened 7.3.0-r3 p1.4)) #6 PREEMPT Wed Mar 6 08:35:59 CET 2019 [0.00] CPU: ARMv7 Processor [411fc083] revision 3 (ARMv7), cr=10c5387d [0.00] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache [0.00] OF: fdt: Machine model: Nokia N900 [0.00] Memory policy: Data cache writeback [0.00] On node 0 totalpages: 65280 [0.00] Normal zone: 510 pages used for memmap [0.00] Normal zone: 0 pages reserved [0.00] Normal zone: 65280 pages, LIFO batch:15 [0.00] CPU: All CPU(s) started in SVC mode. [0.00] OMAP3430/3530 ES3.1 (l2cache iva sgx neon isp) [0.00] random: get_random_bytes called from start_kernel+0x80/0x3fc with crng_init=0 [0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 [0.00] pcpu-alloc: [0] 0 [0.00] Built 1 zonelists, mobility grouping on. Total pages: 64770 [0.00] Kernel command line: root=/dev/mmcblk0p2 rootwait rw mtdoops.mtddev=log console=tty1 omapfb.vram=0:4M omapfb.mode=lcd:848x480-16 nokia-modem.pm=1 [0.00] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) [0.00] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) [0.00] Memory: 216140K/261120K available (6144K kernel code, 258K rwdata, 1856K rodata, 1024K init, 32920K bss, 44980K reserved, 0K cma-reserved, 0K highmem) [0.00] Virtual kernel memory layout: vector : 0x - 0x1000 ( 4 kB) fixmap : 0xffc0 - 0xfff0 (3072 kB) vmalloc : 0xd000 - 0xff80 ( 760 MB) lowmem : 0xc000 - 0xcff0 ( 255 MB) pkmap : 0xbfe0 - 0xc000 ( 2 MB) modules : 0xbf00 - 0xbfe0 ( 14 MB) .text : 0x(ptrval) - 0x(ptrval) (7136 kB) .init : 0x(ptrval) - 0x(ptrval) (1024 kB) .data : 0x(ptrval) - 0x(ptrval) ( 259 kB) .bss : 0x(ptrval) - 0x(ptrval) (32921 kB) [0.00] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1 [0.00] rcu: Preemptible hierarchical RCU implementation. [0.00] Tasks RCU enabled. [0.00] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies. [0.00] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16 [0.00] IRQ: Found an INTC at 0x(ptrval) (revision 4.0) with 96 interrupts [0.00] Clocking rate (Crystal/Core/MPU): 19.2/332/500 MHz [0.00] OMAP clockevent source: timer1 at 32768 Hz [0.00] clocksource: 32k_counter: mask: 0x max_cycles: 0x, max_idle_ns: 58327039986419 ns [0.30] sched_clock: 32 bits at 32kHz, resolution 30517ns, wraps every 6553584741ns [0.30] OMAP clocksource: 32k_counter at 32768 Hz [0.000579] Console: colour dummy device 80x30 [0.001647] printk: console [tty1] enabled [0.001708] Calibrating delay loop... 496.43 BogoMIPS (lpj=2482176) [0.048919] pid_max: default: 32768 minimum: 301 [0.049133] LSM: Security Framework initializing [0.049255] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes) [0.049316] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes) [0.050628] CPU: Testing write buffer coherency: ok [0.050750] CPU0: Spectre v2: using BPIALL workaround [0.052307] Setting up static identity map for 0x8010 - 0x80100060 [0.052612] rcu: Hierarchical SRCU implementation. [0.056457] devtmpfs: initialized [0.086242] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 1 [0.086944] clocksource: jiffies: mask: 0x max_cycles: 0x, max_idle_ns: 1911260446275 ns [0.087036] futex hash table entries: 256 (order: -1, 3072 bytes) [0.087280] xor: measuring software checksum speed [0.178619]arm4regs : 623.600 MB/sec [0.278381]8regs : 459.600 MB/sec [0.378173]32regs: 600.000 MB/sec [0.477966]neon : 444.800 MB/sec [0.477996] xor: using function: arm4regs (623.600 MB/sec) [0.478149] pinctrl core: initialized pinctrl subsystem [0.479644] NET: Registered protocol family 16 [0.481414] DMA: preallocated 256 KiB pool for atomic coherent allocations [0.501464] omap_hwmod: mcbsp2_sidetone using broken dt data from mcbsp [0.502136] omap_hwmod: mcbsp3_sidetone using broken dt data from
Re: [PATCH] Input: raspberrypi-ts: select CONFIG_INPUT_POLLDEV
On Tue, Mar 05, 2019 at 11:39:42AM +0100, Nicolas Saenz Julienne wrote: > On Mon, 2019-03-04 at 20:57 +0100, Arnd Bergmann wrote: > > When CONFIG_INPUT_POLLDEV is disabled, we get a link error: > > > > drivers/input/touchscreen/raspberrypi-ts.o: In function `rpi_ts_probe': > > raspberrypi-ts.c:(.text+0xec): undefined reference to > > `devm_input_allocate_polled_device' > > raspberrypi-ts.c:(.text+0xec): relocation truncated to fit: R_AARCH64_CALL26 > > against undefined symbol `devm_input_allocate_polled_device' > > raspberrypi-ts.c:(.text+0x19c): undefined reference to > > `input_register_polled_device' > > raspberrypi-ts.c:(.text+0x19c): relocation truncated to fit: > > R_AARCH64_CALL26 > > against undefined symbol `input_register_polled_device' > > > > Select that symbol like we do from the other similar drivers. > > > > Fixes: 0b9f28fed3f7 ("Input: add official Raspberry Pi's touchscreen > > driver") > > Signed-off-by: Arnd Bergmann > > --- > > drivers/input/touchscreen/Kconfig | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/drivers/input/touchscreen/Kconfig > > b/drivers/input/touchscreen/Kconfig > > index 7c597a49c265..7a4884ad198b 100644 > > --- a/drivers/input/touchscreen/Kconfig > > +++ b/drivers/input/touchscreen/Kconfig > > @@ -699,6 +699,7 @@ config TOUCHSCREEN_EDT_FT5X06 > > config TOUCHSCREEN_RASPBERRYPI_FW > > tristate "Raspberry Pi's firmware base touch screen support" > > depends on RASPBERRYPI_FIRMWARE || (RASPBERRYPI_FIRMWARE=n && > > COMPILE_TEST) > > + select INPUT_POLLDEV > > help > > Say Y here if you have the official Raspberry Pi 7 inch screen on > > your system. > > Thanks! > Looks good to me. > > Reviewed-by: Nicolas Saenz Julienne > Applied, thank you. -- Dmitry
Re: [PATCH] Input: msm-vibrator: use correct gpio header
On Tue, Mar 05, 2019 at 08:49:01AM +0100, Linus Walleij wrote: > On Mon, Mar 4, 2019 at 8:57 PM Arnd Bergmann wrote: > > > When CONFIG_GPIOLIB is not set, we get a couple of build > > errors during test building: > > > > drivers/input/misc/msm-vibrator.c: In function 'msm_vibrator_start': > > drivers/input/misc/msm-vibrator.c:79:3: error: implicit declaration of > > function 'gpiod_set_value_cansleep'; did you mean > > 'gpio_set_value_cansleep'? [-Werror=implicit-function-declaration] > >gpiod_set_value_cansleep(vibrator->enable_gpio, 1); > >^~~~ > >gpio_set_value_cansleep > > drivers/input/misc/msm-vibrator.c: In function 'msm_vibrator_probe': > > drivers/input/misc/msm-vibrator.c:176:26: error: implicit declaration of > > function 'devm_gpiod_get'; did you mean 'devm_gpio_free'? > > [-Werror=implicit-function-declaration] > > vibrator->enable_gpio = devm_gpiod_get(>dev, "enable", > > ^~ > > devm_gpio_free > > drivers/input/misc/msm-vibrator.c:177:13: error: 'GPIOD_OUT_LOW' undeclared > > (first use in this function); did you mean 'GPIOF_INIT_LOW'? > > GPIOD_OUT_LOW); > > ^ > > GPIOF_INIT_LOW > > drivers/input/misc/msm-vibrator.c:177:13: note: each undeclared identifier > > is reported only once for each function it appears in > > > > This is easy to avoid when we use gpio/consumer.h as the documented > > interface. > > > > Fixes: 0f681d09e66e ("Input: add new vibrator driver for various MSM SOCs") > > Signed-off-by: Arnd Bergmann > > Reviewed-by: Linus Walleij Applied, thank you. -- Dmitry
Re: [PATCH] vhost: silence an unused-variable warning
On Fri, Mar 08, 2019 at 03:17:26PM -0800, David Miller wrote: > From: Arnd Bergmann > Date: Wed, 6 Mar 2019 12:05:49 +0100 > > > On some architectures, the MMU can be disabled, leading to access_ok() > > becoming an empty macro that does not evaluate its size argument, > > which in turn produces an unused-variable warning: > > > > drivers/vhost/vhost.c:1191:9: error: unused variable 's' > > [-Werror,-Wunused-variable] > > size_t s = vhost_has_feature(vq, VIRTIO_RING_F_EVENT_IDX) ? 2 : 0; > > > > Mark the variable as __maybe_unused to shut up that warning. > > > > Signed-off-by: Arnd Bergmann > > I'll apply this, thanks Arnd. I queued this for next linux already and it's been in linux-next for a while. Sorry that I didn't reply, will try to remember to do it next time.
Re: [GIT PULL] PCI changes for v5.1
The pull request you sent on Fri, 8 Mar 2019 11:31:54 -0600: > git://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git > tags/pci-v5.1-changes has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/2901752c14b8e1b7dd898d2e5245c93e531aa624 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL for v5.1-rc1] media updates
The pull request you sent on Thu, 7 Mar 2019 13:24:08 -0300: > git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media media/v5.1-1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/96a6de1a541c86e9e67b9c310c14db4099bd1cbc Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [PATCH v5 6/7] refactor header includes to allow kthread.h inclusion in psi_types.h
Hi Suren, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.0] [cannot apply to next-20190306] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Suren-Baghdasaryan/psi-pressure-stall-monitors-v5/20190310-024018 config: i386-randconfig-a0-201910 (attached as .config) compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): drivers/spi/spi-rockchip.c:328:8: error: unknown type name 'irqreturn_t' static irqreturn_t rockchip_spi_isr(int irq, void *dev_id) ^ drivers/spi/spi-rockchip.c: In function 'rockchip_spi_isr': drivers/spi/spi-rockchip.c:343:9: error: 'IRQ_HANDLED' undeclared (first use in this function) return IRQ_HANDLED; ^ drivers/spi/spi-rockchip.c:343:9: note: each undeclared identifier is reported only once for each function it appears in drivers/spi/spi-rockchip.c: In function 'rockchip_spi_probe': >> drivers/spi/spi-rockchip.c:649:2: error: implicit declaration of function >> 'devm_request_threaded_irq' [-Werror=implicit-function-declaration] ret = devm_request_threaded_irq(>dev, ret, rockchip_spi_isr, NULL, ^ drivers/spi/spi-rockchip.c:650:4: error: 'IRQF_ONESHOT' undeclared (first use in this function) IRQF_ONESHOT, dev_name(>dev), master); ^ cc1: some warnings being treated as errors vim +/devm_request_threaded_irq +649 drivers/spi/spi-rockchip.c 64e36824b addy ke 2014-07-01 592 64e36824b addy ke 2014-07-01 593 static int rockchip_spi_probe(struct platform_device *pdev) 64e36824b addy ke 2014-07-01 594 { 43de979dd Jeffy Chen 2017-08-07 595 int ret; 64e36824b addy ke 2014-07-01 596 struct rockchip_spi *rs; 64e36824b addy ke 2014-07-01 597 struct spi_master *master; 64e36824b addy ke 2014-07-01 598 struct resource *mem; 76b17e6e4 Julius Werner2015-03-26 599 u32 rsd_nsecs; 64e36824b addy ke 2014-07-01 600 64e36824b addy ke 2014-07-01 601 master = spi_alloc_master(>dev, sizeof(struct rockchip_spi)); 5dcc44ed9 Addy Ke 2014-07-11 602 if (!master) 64e36824b addy ke 2014-07-01 603 return -ENOMEM; 5dcc44ed9 Addy Ke 2014-07-11 604 64e36824b addy ke 2014-07-01 605 platform_set_drvdata(pdev, master); 64e36824b addy ke 2014-07-01 606 64e36824b addy ke 2014-07-01 607 rs = spi_master_get_devdata(master); 64e36824b addy ke 2014-07-01 608 64e36824b addy ke 2014-07-01 609 /* Get basic io resource and map it */ 64e36824b addy ke 2014-07-01 610 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 64e36824b addy ke 2014-07-01 611 rs->regs = devm_ioremap_resource(>dev, mem); 64e36824b addy ke 2014-07-01 612 if (IS_ERR(rs->regs)) { 64e36824b addy ke 2014-07-01 613 ret = PTR_ERR(rs->regs); c351587e2 Jeffy Chen 2017-06-13 614 goto err_put_master; 64e36824b addy ke 2014-07-01 615 } 64e36824b addy ke 2014-07-01 616 64e36824b addy ke 2014-07-01 617 rs->apb_pclk = devm_clk_get(>dev, "apb_pclk"); 64e36824b addy ke 2014-07-01 618 if (IS_ERR(rs->apb_pclk)) { 64e36824b addy ke 2014-07-01 619 dev_err(>dev, "Failed to get apb_pclk\n"); 64e36824b addy ke 2014-07-01 620 ret = PTR_ERR(rs->apb_pclk); c351587e2 Jeffy Chen 2017-06-13 621 goto err_put_master; 64e36824b addy ke 2014-07-01 622 } 64e36824b addy ke 2014-07-01 623 64e36824b addy ke 2014-07-01 624 rs->spiclk = devm_clk_get(>dev, "spiclk"); 64e36824b addy ke 2014-07-01 625 if (IS_ERR(rs->spiclk)) { 64e36824b addy ke 2014-07-01 626 dev_err(>dev, "Failed to get spi_pclk\n"); 64e36824b addy ke 2014-07-01 627 ret = PTR_ERR(rs->spiclk); c351587e2 Jeffy Chen 2017-06-13 628 goto err_put_master; 64e36824b addy ke 2014-07-01 629 } 64e36824b addy ke 2014-07-01 630 64e36824b addy ke 2014-07-01 631 ret = clk_prepare_enable(rs->apb_pclk); 43de979dd Jeffy Chen 2017-08-07 632 if (ret < 0) { 64e36824b addy ke 2014-07-01 633 dev_err(>dev, "Failed to enable
Re: [PATCH 4.20 00/76] 4.20.15-stable review
On 3/8/19 4:49 AM, Greg Kroah-Hartman wrote: This is the start of the stable review cycle for the 4.20.15 release. There are 76 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Sun Mar 10 12:48:49 UTC 2019. Anything received after that time might be too late. Build results: total: 159 pass: 159 fail: 0 Qemu test results: total: 343 pass: 343 fail: 0 Guenter
Re: [PATCH 5.0 00/46] 5.0.1-stable review
On 3/8/19 4:49 AM, Greg Kroah-Hartman wrote: This is the start of the stable review cycle for the 5.0.1 release. There are 46 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Sun Mar 10 12:48:36 UTC 2019. Anything received after that time might be too late. Build results: total: 159 pass: 159 fail: 0 Qemu test results: total: 343 pass: 343 fail: 0 Guenter
Re: [PATCH 4.19 00/68] 4.19.28-stable review
On 3/8/19 4:49 AM, Greg Kroah-Hartman wrote: This is the start of the stable review cycle for the 4.19.28 release. There are 68 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know. Responses should be made by Sun Mar 10 12:48:45 UTC 2019. Anything received after that time might be too late. Build results: total: 156 pass: 156 fail: 0 Qemu test results: total: 343 pass: 343 fail: 0 Guenter
Inquiry March-2019
Hi,friend, This is Daniel Murray and i am from Sinara Group Co.,LTD in Russia. We are glad to know about your company from the web and we are interested in your products. Could you kindly send us your Latest catalog and price list for our trial order. Thanks and Best Regards, Daniel Murray Purchasing Manager Sinara Group Co.,LTD
Inquiry March-2019
Hi,friend, This is Daniel Murray and i am from Sinara Group Co.,LTD in Russia. We are glad to know about your company from the web and we are interested in your products. Could you kindly send us your Latest catalog and price list for our trial order. Thanks and Best Regards, Daniel Murray Purchasing Manager Sinara Group Co.,LTD
Re: [PATCH 2/3] soc: brcmstb: dpfe: optimize generic_show()
On Mon, 11 Feb 2019 17:24:42 -0800, Markus Mayer wrote: > From: Markus Mayer > > We can pass a (struct priv_data *) to generic_show() rather than a > (struct device *). For two of the three callers of this function, the > change means one less call to dev_get_drvdata(). For the third caller, > it makes no difference. > > Signed-off-by: Markus Mayer > --- Applied to drivers/next, thanks! -- Florian
Re: [PATCH 3/3] soc: brcmstb: dpfe: use byte 3 of registers MR4-MR8
On Mon, 11 Feb 2019 17:24:43 -0800, Markus Mayer wrote: > From: Markus Mayer > > For dual-rank LPDDR4, result data for any command is placed in byte 0 > and byte 3 of the corresponding MR register by the firmware. > Single-rank RAM was supposed to work the same way. However, due to a > firmware bug, result values are only placed in byte 3 of the > corresponding MR register. > > Since byte 3 works for single-rank and dual-rank setups, we change the > Linux driver to always use byte 3, thus returning the correct value in > either case. > > Signed-off-by: Markus Mayer > --- Applied to drivers/next, thanks! -- Florian
Re: [PATCH 1/3] soc: brcmstb: dpfe: use msleep() over udelay()
On Mon, 11 Feb 2019 17:24:41 -0800, Markus Mayer wrote: > From: Markus Mayer > > To be more "scheduler friendly", we use msleep() rather than udelay() > while we wait for the DCPU to respond. > > Signed-off-by: Markus Mayer > --- Applied to drivers/next, thanks! -- Florian
Re: [GIT PULL 1/2] bcm2835-dt-next-2019-03-04
On 3/4/2019 4:02 PM, Eric Anholt wrote: > Hi Florian, > > The following changes since commit ab1b4ef966af90ad79fa3c4c124e47915cddde10: > > ARM: dts: bcm2835-rpi-zero-w: Drop unnecessary pinctrl (2019-02-01 11:56:32 > +0100) > > are available in the Git repository at: > > git://github.com/anholt/linux tags/bcm2835-dt-next-2019-03-04 > > for you to fetch changes up to 544e784188f1dd7c797c70b213385e67d92005b6: > > ARM: dts: bcm283x: Fix hdmi hpd gpio pull (2019-03-04 15:50:10 -0800) > > > This pull request brings in a fix for detecting HDMI on the Pi B rev 2. > > Merged into devicetree/fixes, will send this out once v5.0-rc1 is tagged. -- Florian
Re: [PATCH v4 1/2] Provide in-kernel headers for making it easy to extend the kernel
Hi Geert, On 3/9/19 2:26 PM, Geert Uytterhoeven wrote: Thanks for the explanation! Happy this was useful :) So how does this work, with kernel images and kernel modules supplied by separate parties, not "bound" by the same kernel headers/API, as they can be replaced separately? The thing with Android is that there isn't a "one size fits all". Google provides guidance, policies and at least one example implementation through the Pixel lines. Each vendor however is allowed a great degree of latitude with regards to what they decide to do. Personally, if I was advising a team working on an Android device where Joel's patch was available as part of their kernel I would just recommend that they build it in -- i.e. not as a module. Hence, there would be no module chasing game. With regards to Google's guidelines for manufacturers, though, Google states that CONFIG_MODVERSIONS needs to be enabled, see here: https://source.android.com/devices/architecture/kernel/modular-kernels FWIW, that doesn't mean that modules are actually used. Devices don't necessarily have to be using modules. Isn't the need for kernel headers for user-space tools something different, as this is limited to the uapi versions, which are less (almost not) subject to change, compared to the kernel headers needed for compiling kernel modules? Sorry, I should've been clearer. I'm including eBPF/BCC into the "user-space tools" here. That was in fact my prime motivation in encouraging Joel at the last LPC to look at this. I've been integrating the teaching of eBPF into my AOSP debugging and performance analysis class (see CC courseware here: http://www.opersys.com/training/android-debug-and-performance), and it was pretty messy trying to show people how to benefit from such tools under Android. Joel's present set of patches would obviate this problem. HTH, -- Karim Yaghmour CEO - Opersys inc. / www.opersys.com http://twitter.com/karimyaghmour
[PATCH v4] blkcg: prevent priority inversion problem during sync()
When sync(2) is executed from a high-priority cgroup, the process is forced to wait the completion of the entire outstanding writeback I/O, even the I/O that was originally generated by low-priority cgroups potentially. This may cause massive latencies to random processes (even those running in the root cgroup) that shouldn't be I/O-throttled at all, similarly to a classic priority inversion problem. Prevent this problem by saving a list of blkcg's that are waiting for writeback: every time a sync(2) is executed the current blkcg is added to the list. Then, when I/O is throttled, if there's a blkcg waiting for writeback different than the current blkcg, no throttling is applied (we can probably refine this logic later, i.e., a better policy could be to adjust the I/O rate using the blkcg with the highest speed from the list of waiters). See also: https://lkml.org/lkml/2019/3/7/640 Signed-off-by: Andrea Righi --- Changes in v4: - fix a build bug when CONFIG_BLOCK is unset block/blk-cgroup.c | 130 +++ block/blk-throttle.c | 11 ++- fs/fs-writeback.c| 5 ++ fs/sync.c| 8 +- include/linux/backing-dev-defs.h | 2 + include/linux/blk-cgroup.h | 35 - mm/backing-dev.c | 2 + 7 files changed, 188 insertions(+), 5 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 77f37ef8ef06..5334cb3acd22 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1351,6 +1351,136 @@ struct cgroup_subsys io_cgrp_subsys = { }; EXPORT_SYMBOL_GPL(io_cgrp_subsys); +#ifdef CONFIG_CGROUP_WRITEBACK +struct blkcg_wb_sleeper { + struct blkcg *blkcg; + refcount_t refcnt; + struct list_head node; +}; + +static struct blkcg_wb_sleeper * +blkcg_wb_sleeper_find(struct blkcg *blkcg, struct backing_dev_info *bdi) +{ + struct blkcg_wb_sleeper *bws; + + list_for_each_entry(bws, >cgwb_waiters, node) + if (bws->blkcg == blkcg) + return bws; + return NULL; +} + +static void +blkcg_wb_sleeper_add(struct backing_dev_info *bdi, struct blkcg_wb_sleeper *bws) +{ + list_add(>node, >cgwb_waiters); +} + +static void +blkcg_wb_sleeper_del(struct backing_dev_info *bdi, struct blkcg_wb_sleeper *bws) +{ + list_del_init(>node); +} + +/** + * blkcg_wb_waiters_on_bdi - check for writeback waiters on a block device + * @blkcg: current blkcg cgroup + * @bdi: block device to check + * + * Return true if any other blkcg different than the current one is waiting for + * writeback on the target block device, false otherwise. + */ +bool blkcg_wb_waiters_on_bdi(struct blkcg *blkcg, struct backing_dev_info *bdi) +{ + struct blkcg_wb_sleeper *bws; + bool ret = false; + + if (likely(list_empty(>cgwb_waiters))) + return false; + spin_lock(>cgwb_waiters_lock); + list_for_each_entry(bws, >cgwb_waiters, node) + if (bws->blkcg != blkcg) { + ret = true; + break; + } + spin_unlock(>cgwb_waiters_lock); + + return ret; +} + +/** + * blkcg_start_wb_wait_on_bdi - add current blkcg to writeback waiters list + * @bdi: target block device + * + * Add current blkcg to the list of writeback waiters on target block device. + */ +void blkcg_start_wb_wait_on_bdi(struct backing_dev_info *bdi) +{ + struct blkcg_wb_sleeper *new_bws, *bws; + struct blkcg *blkcg; + + new_bws = kzalloc(sizeof(*new_bws), GFP_KERNEL); + if (unlikely(!new_bws)) + return; + + rcu_read_lock(); + blkcg = blkcg_from_current(); + if (likely(blkcg)) { + /* Check if blkcg is already sleeping on bdi */ + spin_lock_bh(>cgwb_waiters_lock); + bws = blkcg_wb_sleeper_find(blkcg, bdi); + if (bws) { + refcount_inc(>refcnt); + } else { + /* Add current blkcg as a new wb sleeper on bdi */ + css_get(>css); + new_bws->blkcg = blkcg; + refcount_set(_bws->refcnt, 1); + blkcg_wb_sleeper_add(bdi, new_bws); + new_bws = NULL; + } + spin_unlock_bh(>cgwb_waiters_lock); + } + rcu_read_unlock(); + + kfree(new_bws); +} + +/** + * blkcg_stop_wb_wait_on_bdi - remove current blkcg from writeback waiters list + * @bdi: target block device + * + * Remove current blkcg from the list of writeback waiters on target block + * device. + */ +void blkcg_stop_wb_wait_on_bdi(struct backing_dev_info *bdi) +{ + struct blkcg_wb_sleeper *bws = NULL; + struct blkcg *blkcg; + + rcu_read_lock(); + blkcg = blkcg_from_current(); + if (!blkcg) { + rcu_read_unlock(); + return; + } +
[tip:sched/urgent 1/5] kernel/sched/cpufreq_schedutil.c:346:40: sparse: error: incompatible types in comparison expression (different type sizes):
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git sched/urgent head: ce28d2e53cda890771360d32259495dd6a9c4253 commit: f1212844e9dc3a31d41f99713c5522acf92ff291 [1/5] sched/cpufreq: Fix 32-bit math overflow reproduce: # apt-get install sparse git checkout f1212844e9dc3a31d41f99713c5522acf92ff291 make ARCH=x86_64 allmodconfig make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' All errors (new ones prefixed by >>): >> kernel/sched/cpufreq_schedutil.c:346:40: sparse: error: incompatible types >> in comparison expression (different type sizes): kernel/sched/cpufreq_schedutil.c:346:40: sparse:unsigned int * kernel/sched/cpufreq_schedutil.c:346:40: sparse:long * kernel/sched/cpufreq_schedutil.c:612:25: sparse: warning: symbol 'schedutil_gov' was not declared. Should it be static? sparse warnings: (new ones prefixed by >>) kernel/sched/cpufreq_schedutil.c:346:40: sparse: error: incompatible types in comparison expression (different type sizes): >> kernel/sched/cpufreq_schedutil.c:346:40: sparse:unsigned int * >> kernel/sched/cpufreq_schedutil.c:346:40: sparse:long * vim +346 kernel/sched/cpufreq_schedutil.c 311 312 /** 313 * sugov_iowait_boost() - Updates the IO boost status of a CPU. 314 * @sg_cpu: the sugov data for the CPU to boost 315 * @time: the update time from the caller 316 * @flags: SCHED_CPUFREQ_IOWAIT if the task is waking up after an IO wait 317 * 318 * Each time a task wakes up after an IO operation, the CPU utilization can be 319 * boosted to a certain utilization which doubles at each "frequent and 320 * successive" wakeup from IO, ranging from the utilization of the minimum 321 * OPP to the utilization of the maximum OPP. 322 * To keep doubling, an IO boost has to be requested at least once per tick, 323 * otherwise we restart from the utilization of the minimum OPP. 324 */ 325 static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time, 326 unsigned int flags) 327 { 328 bool set_iowait_boost = flags & SCHED_CPUFREQ_IOWAIT; 329 330 /* Reset boost if the CPU appears to have been idle enough */ 331 if (sg_cpu->iowait_boost && 332 sugov_iowait_reset(sg_cpu, time, set_iowait_boost)) 333 return; 334 335 /* Boost only tasks waking up after IO */ 336 if (!set_iowait_boost) 337 return; 338 339 /* Ensure boost doubles only one time at each request */ 340 if (sg_cpu->iowait_boost_pending) 341 return; 342 sg_cpu->iowait_boost_pending = true; 343 344 /* Double the boost at each request */ 345 if (sg_cpu->iowait_boost) { > 346 sg_cpu->iowait_boost = min(sg_cpu->iowait_boost << 1, > SCHED_CAPACITY_SCALE); 347 return; 348 } 349 350 /* First wakeup after IO: start with minimum boost */ 351 sg_cpu->iowait_boost = sg_cpu->min; 352 } 353 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH 1/5] lib/sort: Make swap functions more generic
Andy Shevchenko wrote: > Shouldn't simple memcpy cover these case for both 32- and 64-bit > architectures? Speaking of replacing swap with copying via temporary buffers, one idea that did come to mind was avoiding swap for sufficiently small objects. Every sift-down is actually a circular shift. Once the target position hs been found, we rotate the path from the root to the target up one, with the target filled in by the previous root. (When breaking down the heap, there's one additional link in the cycle, where the previous root goes to the end of the heap and the end of the heap goes to the target.) If we had a temporary buffer (128 bytes would handle most things), we could copy the previous root there and *copy*, rather than swap, the elements on the path to the target up, then finally copy the previous root to the target. However, to rotate up, the this must be done in top-down order. The way the code currently works with premultiplied offsets, it's easy to traverse bottom-up, but very awkward to retrace the top-down path. The only solution I can think of is to build a bitmap of the left/right turnings from the root to the leaf, and then back it up to the target. There are a few ways to do this: 1) The obvious big-endian order. The bitmap is simply the 1-based position of the leaf. To add a level, shift left and add the new bit at the bottom. To back up a step, shift right. To retrace, create a 1-bit mask equal to the msbit of the index ((smear_right(x) >> 1) + 1) and repeatedly shift the mask right. 2) The reverse order. We use a 1-bit mask while building the bitmap, and while retracing, just examine the lsbit while shifting the bitmap right. 3) As option 1, but don't build the bitmap as we're walking down; rather reconstruct it from the premultiplied offset using reciprocal_divide(). Nothing really jumps out to me as The Right Way to do it. I don't want to bloat the code to the point that it would be easier to implement a different algorithm entirely.
Re: [PATCH v5 6/7] refactor header includes to allow kthread.h inclusion in psi_types.h
Hi Suren, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.0] [cannot apply to next-20190306] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Suren-Baghdasaryan/psi-pressure-stall-monitors-v5/20190310-024018 config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 8.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree GCC_VERSION=8.2.0 make.cross ARCH=ia64 All errors (new ones prefixed by >>): drivers/spi/spi-rockchip.c: In function 'rockchip_spi_probe': >> drivers/spi/spi-rockchip.c:649:8: error: implicit declaration of function >> 'devm_request_threaded_irq'; did you mean 'devm_request_region'? >> [-Werror=implicit-function-declaration] ret = devm_request_threaded_irq(>dev, ret, rockchip_spi_isr, NULL, ^ devm_request_region >> drivers/spi/spi-rockchip.c:650:4: error: 'IRQF_ONESHOT' undeclared (first >> use in this function); did you mean 'SA_ONESHOT'? IRQF_ONESHOT, dev_name(>dev), master); ^~~~ SA_ONESHOT drivers/spi/spi-rockchip.c:650:4: note: each undeclared identifier is reported only once for each function it appears in cc1: some warnings being treated as errors vim +649 drivers/spi/spi-rockchip.c 64e36824b addy ke 2014-07-01 592 64e36824b addy ke 2014-07-01 593 static int rockchip_spi_probe(struct platform_device *pdev) 64e36824b addy ke 2014-07-01 594 { 43de979dd Jeffy Chen 2017-08-07 595 int ret; 64e36824b addy ke 2014-07-01 596 struct rockchip_spi *rs; 64e36824b addy ke 2014-07-01 597 struct spi_master *master; 64e36824b addy ke 2014-07-01 598 struct resource *mem; 76b17e6e4 Julius Werner2015-03-26 599 u32 rsd_nsecs; 64e36824b addy ke 2014-07-01 600 64e36824b addy ke 2014-07-01 601 master = spi_alloc_master(>dev, sizeof(struct rockchip_spi)); 5dcc44ed9 Addy Ke 2014-07-11 602 if (!master) 64e36824b addy ke 2014-07-01 603 return -ENOMEM; 5dcc44ed9 Addy Ke 2014-07-11 604 64e36824b addy ke 2014-07-01 605 platform_set_drvdata(pdev, master); 64e36824b addy ke 2014-07-01 606 64e36824b addy ke 2014-07-01 607 rs = spi_master_get_devdata(master); 64e36824b addy ke 2014-07-01 608 64e36824b addy ke 2014-07-01 609 /* Get basic io resource and map it */ 64e36824b addy ke 2014-07-01 610 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 64e36824b addy ke 2014-07-01 611 rs->regs = devm_ioremap_resource(>dev, mem); 64e36824b addy ke 2014-07-01 612 if (IS_ERR(rs->regs)) { 64e36824b addy ke 2014-07-01 613 ret = PTR_ERR(rs->regs); c351587e2 Jeffy Chen 2017-06-13 614 goto err_put_master; 64e36824b addy ke 2014-07-01 615 } 64e36824b addy ke 2014-07-01 616 64e36824b addy ke 2014-07-01 617 rs->apb_pclk = devm_clk_get(>dev, "apb_pclk"); 64e36824b addy ke 2014-07-01 618 if (IS_ERR(rs->apb_pclk)) { 64e36824b addy ke 2014-07-01 619 dev_err(>dev, "Failed to get apb_pclk\n"); 64e36824b addy ke 2014-07-01 620 ret = PTR_ERR(rs->apb_pclk); c351587e2 Jeffy Chen 2017-06-13 621 goto err_put_master; 64e36824b addy ke 2014-07-01 622 } 64e36824b addy ke 2014-07-01 623 64e36824b addy ke 2014-07-01 624 rs->spiclk = devm_clk_get(>dev, "spiclk"); 64e36824b addy ke 2014-07-01 625 if (IS_ERR(rs->spiclk)) { 64e36824b addy ke 2014-07-01 626 dev_err(>dev, "Failed to get spi_pclk\n"); 64e36824b addy ke 2014-07-01 627 ret = PTR_ERR(rs->spiclk); c351587e2 Jeffy Chen 2017-06-13 628 goto err_put_master; 64e36824b addy ke 2014-07-01 629 } 64e36824b addy ke 2014-07-01 630 64e36824b addy ke 2014-07-01 631 ret = clk_prepare_enable(rs->apb_pclk); 43de979dd Jeffy Chen 2017-08-07 632 if (ret < 0) { 64e36824b addy ke 2014-07-01 633 dev_err(>dev, "Failed to enable apb_pclk\n"); c351587e2 Jeffy Chen 2017-06-13 634
Re: [RFC] sched/fair: hard lockup in sched_cfs_period_timer
On Wed, Mar 06, 2019 at 11:25:02AM -0800 bseg...@google.com wrote: > Phil Auld writes: > > > On Tue, Mar 05, 2019 at 12:45:34PM -0800 bseg...@google.com wrote: > >> Phil Auld writes: > >> > >> > Interestingly, if I limit the number of child cgroups to the number of > >> > them I'm actually putting processes into (16 down from 2500) the problem > >> > does not reproduce. > >> > >> That is indeed interesting, and definitely not something we'd want to > >> matter. (Particularly if it's not root->a->b->c...->throttled_cgroup or > >> root->throttled->a->...->thread vs root->throttled_cgroup, which is what > >> I was originally thinking of) > >> > > > > The locking may be a red herring. > > > > The setup is root->throttled->a where a is 1-2500. There are 4 threads in > > each of the first 16 a groups. The parent, throttled, is where the > > cfs_period/quota_us are set. > > > > I wonder if the problem is the walk_tg_tree_from() call in > > unthrottle_cfs_rq(). > > > > The distribute_cfg_runtime looks to be O(n * m) where n is number of > > throttled cfs_rqs and m is the number of child cgroups. But I'm not > > completely clear on how the hierarchical cgroups play together here. > > > > I'll pull on this thread some. > > > > Thanks for your input. > > > > > > Cheers, > > Phil > > Yeah, that isn't under the cfs_b lock, but is still part of distribute > (and under rq lock, which might also matter). I was thinking too much > about just the cfs_b regions. I'm not sure there's any good general > optimization there. > It's really an edge case, but the watchdog NMI is pretty painful. > I suppose cfs_rqs (tgs/cfs_bs?) could have "nearest > ancestor with a quota" pointer and ones with quota could have > "descendants with quota" list, parallel to the children/parent lists of > tgs. Then throttle/unthrottle would only have to visit these lists, and > child cgroups/cfs_rqs without their own quotas would just check > cfs_rq->nearest_quota_cfs_rq->throttle_count. throttled_clock_task_time > can also probably be tracked there. That seems like it would add a lot of complexity for this edge case. Maybe it would be acceptible to use the safety valve like my first example, or something like the below which will tune the period up until it doesn't overrun for ever. The down side of this one is it does change the user's settings, but that could be preferable to an NMI crash. Cheers, Phil diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 310d0637fe4b..78f9e28adc7b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4859,16 +4859,42 @@ static enum hrtimer_restart sched_cfs_slack_timer(struct hrtimer *timer) return HRTIMER_NORESTART; } +extern const u64 max_cfs_quota_period; +s64 cfs_quota_period_autotune_thresh = 100 * NSEC_PER_MSEC; +int cfs_quota_period_autotune_shift = 4; /* 100 / 16 = 6.25% */ + static enum hrtimer_restart sched_cfs_period_timer(struct hrtimer *timer) { struct cfs_bandwidth *cfs_b = container_of(timer, struct cfs_bandwidth, period_timer); + s64 nsprev, nsnow, new_period; + ktime_t now; int overrun; int idle = 0; raw_spin_lock(_b->lock); + nsprev = ktime_to_ns(hrtimer_cb_get_time(timer)); for (;;) { - overrun = hrtimer_forward_now(timer, cfs_b->period); + /* +* Note this reverts the change to use hrtimer_forward_now, which avoids calling hrtimer_cb_get_time +* for a value we already have +*/ + now = hrtimer_cb_get_time(timer); + nsnow = ktime_to_ns(now); + if (nsnow - nsprev >= cfs_quota_period_autotune_thresh) { + new_period = ktime_to_ns(cfs_b->period); + new_period += new_period >> cfs_quota_period_autotune_shift; + if (new_period <= max_cfs_quota_period) { + cfs_b->period = ns_to_ktime(new_period); + cfs_b->quota += cfs_b->quota >> cfs_quota_period_autotune_shift; + pr_warn_ratelimited( + "cfs_period_timer [cpu%d] : Running too long, scaling up (new period %lld, new quota = %lld)\n", + smp_processor_id(), cfs_b->period/NSEC_PER_USEC, cfs_b->quota/NSEC_PER_USEC); + } + nsprev = nsnow; + } + + overrun = hrtimer_forward(timer, now, cfs_b->period); if (!overrun) break; --
Re: [PATCH] kbuild: add workaround for Debian make-kpkg
On Fri, 2019-03-08 at 15:42 +0900, Masahiro Yamada wrote: > On Fri, Mar 8, 2019 at 6:56 AM Ben Hutchings wrote: [...] > > I take it that you don't want kernel-package to be included in buster, > > so can you open an RC bug to say so? > > Also, could you make sure it won't come back to bullseye or later ? An RC (release-critical) bug will normally block a package from being considered for any future release. > How about Ubuntu? Is it out of your control? Ubuntu's release management is independent of Debian's. I don't know whether they consider RC bugs in Debian. Ben. -- Ben Hutchings Knowledge is power. France is bacon. signature.asc Description: This is a digitally signed message part
Re: [PATCH 1/5] lib/sort: Make swap functions more generic
> Although I'm thinking of: > > static bool __attribute_const__ > is_aligned(const void *base, size_t size, unsigned char align) > { > unsigned char lsbits = (unsigned char)size; > > (void)base; > #ifndef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS > lsbits |= (unsigned char)(uintptr_t)base; > #endif > return (lsbits & (align - 1)) == 0; > } > > Any preference? I think it would be better. > I find "u32s" confusing; I keep reading the "s" as "signed" rather than a > plural. How about one of: swap_bytes / swap_ints / swap_longs swap_1 / swap_4 > / swap_8 In my opinion "swap_bytes / swap_ints / swap_longs" are the most readable. (Good job)
[tip:perf/urgent] perf data: Force perf_data__open|close zero data->file.path
Commit-ID: b8f7d86b5849ea7bb84bddc0345a3799049764d4 Gitweb: https://git.kernel.org/tip/b8f7d86b5849ea7bb84bddc0345a3799049764d4 Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:36 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:21:00 -0300 perf data: Force perf_data__open|close zero data->file.path Making sure the data->file.path is zeroed on perf_data__open error path and in perf_data__close, so we don't double free it in case someone call it twice. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jonas Rabenstein Cc: Nageswara R Sastry Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20190305152536.21035-9-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/data.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 7bd5ddeb7a41..e098e189f93e 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -237,7 +237,7 @@ static int open_file(struct perf_data *data) open_file_read(data) : open_file_write(data); if (fd < 0) { - free(data->file.path); + zfree(>file.path); return -1; } @@ -270,7 +270,7 @@ int perf_data__open(struct perf_data *data) void perf_data__close(struct perf_data *data) { - free(data->file.path); + zfree(>file.path); close(data->file.fd); }
[tip:perf/urgent] perf evsel: Probe for precise_ip with simple attr
Commit-ID: 5b61adb16599be04346e7e943c1b5113b57485ad Gitweb: https://git.kernel.org/tip/5b61adb16599be04346e7e943c1b5113b57485ad Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:34 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:19:45 -0300 perf evsel: Probe for precise_ip with simple attr Currently we probe for precise_ip with user specified perf_event_attr, which might fail because of unsupported kernel features, which would get disabled during the open time anyway. Switching the probe to take place on simple hw cycles, so the following record sets proper precise_ip: # perf record -e cycles:P ls # perf evlist -v cycles:P: size: 112, ... precise_ip: 3, ... Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jonas Rabenstein Cc: Nageswara R Sastry Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20190305152536.21035-7-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/evlist.c | 25 - tools/perf/util/evsel.c | 8 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/tools/perf/util/evlist.c b/tools/perf/util/evlist.c index 08cedb643ea6..ed20f4379956 100644 --- a/tools/perf/util/evlist.c +++ b/tools/perf/util/evlist.c @@ -230,18 +230,33 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) } } -void perf_event_attr__set_max_precise_ip(struct perf_event_attr *attr) +void perf_event_attr__set_max_precise_ip(struct perf_event_attr *pattr) { - attr->precise_ip = 3; + struct perf_event_attr attr = { + .type = PERF_TYPE_HARDWARE, + .config = PERF_COUNT_HW_CPU_CYCLES, + .exclude_kernel = 1, + .precise_ip = 3, + }; - while (attr->precise_ip != 0) { - int fd = sys_perf_event_open(attr, 0, -1, -1, 0); + event_attr_init(); + + /* +* Unnamed union member, not supported as struct member named +* initializer in older compilers such as gcc 4.4.7 +*/ + attr.sample_period = 1; + + while (attr.precise_ip != 0) { + int fd = sys_perf_event_open(, 0, -1, -1, 0); if (fd != -1) { close(fd); break; } - --attr->precise_ip; + --attr.precise_ip; } + + pattr->precise_ip = attr.precise_ip; } int __perf_evlist__add_default(struct perf_evlist *evlist, bool precise) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index dfe2958e6287..3bbf73e979c0 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -294,20 +294,12 @@ struct perf_evsel *perf_evsel__new_cycles(bool precise) if (!precise) goto new_event; - /* -* Unnamed union member, not supported as struct member named -* initializer in older compilers such as gcc 4.4.7 -* -* Just for probing the precise_ip: -*/ - attr.sample_period = 1; perf_event_attr__set_max_precise_ip(); /* * Now let the usual logic to set up the perf_event_attr defaults * to kick in when we return and before perf_evsel__open() is called. */ - attr.sample_period = 0; new_event: evsel = perf_evsel__new(); if (evsel == NULL)
[tip:perf/urgent] perf session: Fix double free in perf_data__close
Commit-ID: befa09b61f8bf1d7c34b8e6405f08d804640573c Gitweb: https://git.kernel.org/tip/befa09b61f8bf1d7c34b8e6405f08d804640573c Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:35 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:20:33 -0300 perf session: Fix double free in perf_data__close We can't call perf_data__close and subsequently perf_session__delete, because it will call perf_data__close again and cause double free for data->file.path. $ perf report -i . incompatible file format (rerun with -v to learn more) free(): double free detected in tcache 2 Aborted (core dumped) In fact we don't need to call perf_data__close at all, because at the time the got out_close is reached, session->data is already initialized, so the perf_data__close call will be triggered from perf_session__delete. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jonas Rabenstein Cc: Nageswara R Sastry Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Fixes: 2d4f27999b88 ("perf data: Add global path holder") Link: http://lkml.kernel.org/r/20190305152536.21035-8-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/session.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c index c764bbc91009..db643f3c2b95 100644 --- a/tools/perf/util/session.c +++ b/tools/perf/util/session.c @@ -140,7 +140,7 @@ struct perf_session *perf_session__new(struct perf_data *data, if (perf_data__is_read(data)) { if (perf_session__open(session) < 0) - goto out_close; + goto out_delete; /* * set session attributes that are present in perf.data @@ -181,8 +181,6 @@ struct perf_session *perf_session__new(struct perf_data *data, return session; - out_close: - perf_data__close(data); out_delete: perf_session__delete(session); out:
[tip:perf/urgent] perf hist: Fix memory leak of srcline
Commit-ID: 2634958586368dcbf09c0d2a17dee02d1fc53e0d Gitweb: https://git.kernel.org/tip/2634958586368dcbf09c0d2a17dee02d1fc53e0d Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:31 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:16:57 -0300 perf hist: Fix memory leak of srcline We can't allocate he->srcline unconditionaly, only when new hist_entry is created. Moving he->srcline allocation into hist_entry__init function. Original-patch-by: Jonas Rabenstein Suggested-by: Namhyung Kim Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Nageswara R Sastry Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20190305152536.21035-4-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 74e307d17c49..f9eb95bf3938 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -419,6 +419,13 @@ static int hist_entry__init(struct hist_entry *he, if (he->raw_data == NULL) goto err_infos; } + + if (he->srcline) { + he->srcline = strdup(he->srcline); + if (he->srcline == NULL) + goto err_rawdata; + } + INIT_LIST_HEAD(>pairs.node); thread__get(he->thread); he->hroot_in = RB_ROOT_CACHED; @@ -429,6 +436,9 @@ static int hist_entry__init(struct hist_entry *he, return 0; +err_rawdata: + free(he->raw_data); + err_infos: if (he->branch_info) { map__put(he->branch_info->from.map); @@ -605,7 +615,7 @@ __hists__add_entry(struct hists *hists, .map= al->map, .sym= al->sym, }, - .srcline = al->srcline ? strdup(al->srcline) : NULL, + .srcline = (char *) al->srcline, .socket = al->socket, .cpu = al->cpu, .cpumode = al->cpumode, @@ -962,7 +972,7 @@ iter_add_next_cumulative_entry(struct hist_entry_iter *iter, .map = al->map, .sym = al->sym, }, - .srcline = al->srcline ? strdup(al->srcline) : NULL, + .srcline = (char *) al->srcline, .parent = iter->parent, .raw_data = sample->raw_data, .raw_size = sample->raw_size,
[tip:perf/urgent] perf tools: Read and store caps/max_precise in perf_pmu
Commit-ID: 90a86bde97ba050cb3c9ccb215252ee2d2d705fa Gitweb: https://git.kernel.org/tip/90a86bde97ba050cb3c9ccb215252ee2d2d705fa Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:32 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:18:17 -0300 perf tools: Read and store caps/max_precise in perf_pmu Read the caps/max_precise value and store it in struct perf_pmu to be used when setting the maximum precise_ip field in following patch. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jonas Rabenstein Cc: Nageswara R Sastry Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Link: http://lkml.kernel.org/r/20190305152536.21035-5-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/pmu.c | 14 ++ tools/perf/util/pmu.h | 1 + 2 files changed, 15 insertions(+) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 51d437f55d18..6199a3174ab9 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -752,6 +752,19 @@ perf_pmu__get_default_config(struct perf_pmu *pmu __maybe_unused) return NULL; } +static int pmu_max_precise(const char *name) +{ + char path[PATH_MAX]; + int max_precise = -1; + + scnprintf(path, PATH_MAX, +"bus/event_source/devices/%s/caps/max_precise", +name); + + sysfs__read_int(path, _precise); + return max_precise; +} + static struct perf_pmu *pmu_lookup(const char *name) { struct perf_pmu *pmu; @@ -784,6 +797,7 @@ static struct perf_pmu *pmu_lookup(const char *name) pmu->name = strdup(name); pmu->type = type; pmu->is_uncore = pmu_is_uncore(name); + pmu->max_precise = pmu_max_precise(name); pmu_add_cpu_aliases(, pmu); INIT_LIST_HEAD(>format); diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h index 47253c3daf55..bd9ec2704a57 100644 --- a/tools/perf/util/pmu.h +++ b/tools/perf/util/pmu.h @@ -26,6 +26,7 @@ struct perf_pmu { __u32 type; bool selectable; bool is_uncore; + int max_precise; struct perf_event_attr *default_config; struct cpu_map *cpus; struct list_head format; /* HEAD struct perf_pmu_format -> list */
[tip:perf/urgent] perf hist: Add error path into hist_entry__init
Commit-ID: c57589106fd6d996dbf3757708baa4a3fb91850f Gitweb: https://git.kernel.org/tip/c57589106fd6d996dbf3757708baa4a3fb91850f Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:30 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:16:30 -0300 perf hist: Add error path into hist_entry__init Adding error path into hist_entry__init to unify error handling, so every new member does not need to free everything else. Signed-off-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jonas Rabenstein Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Ravi Bangoria Cc: nageswara r sastry Link: http://lkml.kernel.org/r/20190305152536.21035-3-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/hist.c | 39 +++ 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tools/perf/util/hist.c b/tools/perf/util/hist.c index 669f961316f0..74e307d17c49 100644 --- a/tools/perf/util/hist.c +++ b/tools/perf/util/hist.c @@ -396,11 +396,8 @@ static int hist_entry__init(struct hist_entry *he, * adding new entries. So we need to save a copy. */ he->branch_info = malloc(sizeof(*he->branch_info)); - if (he->branch_info == NULL) { - map__zput(he->ms.map); - free(he->stat_acc); - return -ENOMEM; - } + if (he->branch_info == NULL) + goto err; memcpy(he->branch_info, template->branch_info, sizeof(*he->branch_info)); @@ -419,21 +416,8 @@ static int hist_entry__init(struct hist_entry *he, if (he->raw_data) { he->raw_data = memdup(he->raw_data, he->raw_size); - - if (he->raw_data == NULL) { - map__put(he->ms.map); - if (he->branch_info) { - map__put(he->branch_info->from.map); - map__put(he->branch_info->to.map); - free(he->branch_info); - } - if (he->mem_info) { - map__put(he->mem_info->iaddr.map); - map__put(he->mem_info->daddr.map); - } - free(he->stat_acc); - return -ENOMEM; - } + if (he->raw_data == NULL) + goto err_infos; } INIT_LIST_HEAD(>pairs.node); thread__get(he->thread); @@ -444,6 +428,21 @@ static int hist_entry__init(struct hist_entry *he, he->leaf = true; return 0; + +err_infos: + if (he->branch_info) { + map__put(he->branch_info->from.map); + map__put(he->branch_info->to.map); + free(he->branch_info); + } + if (he->mem_info) { + map__put(he->mem_info->iaddr.map); + map__put(he->mem_info->daddr.map); + } +err: + map__zput(he->ms.map); + free(he->stat_acc); + return -ENOMEM; } static void *hist_entry__zalloc(size_t size)
[tip:perf/urgent] perf c2c: Fix c2c report for empty numa node
Commit-ID: e34c940245437f36d2c492edd1f8237eff391064 Gitweb: https://git.kernel.org/tip/e34c940245437f36d2c492edd1f8237eff391064 Author: Jiri Olsa AuthorDate: Tue, 5 Mar 2019 16:25:29 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:15:24 -0300 perf c2c: Fix c2c report for empty numa node Ravi Bangoria reported that we fail with an empty NUMA node with the following message: $ lscpu NUMA node0 CPU(s): NUMA node1 CPU(s): 0-4 $ sudo ./perf c2c report node/cpu topology bugFailed setup nodes Fix this by detecting the empty node and keeping its CPU set empty. Reported-by: Nageswara R Sastry Signed-off-by: Jiri Olsa Tested-by: Ravi Bangoria Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jonas Rabenstein Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20190305152536.21035-2-jo...@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-c2c.c | 8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/builtin-c2c.c b/tools/perf/builtin-c2c.c index 4272763a5e96..9e6cc868bdb4 100644 --- a/tools/perf/builtin-c2c.c +++ b/tools/perf/builtin-c2c.c @@ -2056,6 +2056,12 @@ static int setup_nodes(struct perf_session *session) if (!set) return -ENOMEM; + nodes[node] = set; + + /* empty node, skip */ + if (cpu_map__empty(map)) + continue; + for (cpu = 0; cpu < map->nr; cpu++) { set_bit(map->map[cpu], set); @@ -2064,8 +2070,6 @@ static int setup_nodes(struct perf_session *session) cpu2node[map->map[cpu]] = node; } - - nodes[node] = set; } setup_nodes_header();
[tip:perf/urgent] perf script python: Add Python3 support to intel-pt-events.py
Commit-ID: fdf2460c297f1bb2f3bd20b3b52903b267af9050 Gitweb: https://git.kernel.org/tip/fdf2460c297f1bb2f3bd20b3b52903b267af9050 Author: Tony Jones AuthorDate: Tue, 5 Mar 2019 08:19:02 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:12:33 -0300 perf script python: Add Python3 support to intel-pt-events.py Support both Python2 and Python3 in the intel-pt-events.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones Acked-by: Adrian Hunter Link: http://lkml.kernel.org/r/fd26acf9-0c0f-717f-9664-a3c33043c...@suse.de Signed-off-by: Seeteena Thoufeek Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/intel-pt-events.py | 32 +--- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/tools/perf/scripts/python/intel-pt-events.py b/tools/perf/scripts/python/intel-pt-events.py index 2177722f509e..a73847c8f548 100644 --- a/tools/perf/scripts/python/intel-pt-events.py +++ b/tools/perf/scripts/python/intel-pt-events.py @@ -10,6 +10,8 @@ # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # more details. +from __future__ import print_function + import os import sys import struct @@ -22,34 +24,34 @@ sys.path.append(os.environ['PERF_EXEC_PATH'] + \ #from Core import * def trace_begin(): - print "Intel PT Power Events and PTWRITE" + print("Intel PT Power Events and PTWRITE") def trace_end(): - print "End" + print("End") def trace_unhandled(event_name, context, event_fields_dict): - print ' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]) + print(' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())])) def print_ptwrite(raw_buf): data = struct.unpack_from("> 32) & 0x3 - print "hints: %#x extensions: %#x" % (hints, extensions), + print("hints: %#x extensions: %#x" % (hints, extensions), end=' ') def print_pwre(raw_buf): data = struct.unpack_from("> 7) & 1 cstate = (payload >> 12) & 0xf subcstate = (payload >> 8) & 0xf - print "hw: %u cstate: %u sub-cstate: %u" % (hw, cstate, subcstate), + print("hw: %u cstate: %u sub-cstate: %u" % (hw, cstate, subcstate), + end=' ') def print_exstop(raw_buf): data = struct.unpack_from("> 4) & 0xf wake_reason = (payload >> 8) & 0xf - print "deepest cstate: %u last cstate: %u wake reason: %#x" % (deepest_cstate, last_cstate, wake_reason), + print("deepest cstate: %u last cstate: %u wake reason: %#x" % + (deepest_cstate, last_cstate, wake_reason), end=' ') def print_common_start(comm, sample, name): ts = sample["time"] cpu = sample["cpu"] pid = sample["pid"] tid = sample["tid"] - print "%16s %5u/%-5u [%03u] %9u.%09u %7s:" % (comm, pid, tid, cpu, ts / 10, ts %10, name), + print("%16s %5u/%-5u [%03u] %9u.%09u %7s:" % + (comm, pid, tid, cpu, ts / 10, ts %10, name), + end=' ') def print_common_ip(sample, symbol, dso): ip = sample["ip"] - print "%16x %s (%s)" % (ip, symbol, dso) + print("%16x %s (%s)" % (ip, symbol, dso)) def process_event(param_dict): event_attr = param_dict["attr"] @@ -92,12 +98,12 @@ def process_event(param_dict): name = param_dict["ev_name"] # Symbol and dso info are not always resolved - if (param_dict.has_key("dso")): + if "dso" in param_dict: dso = param_dict["dso"] else: dso = "[unknown]" - if (param_dict.has_key("symbol")): + if "symbol" in param_dict: symbol = param_dict["symbol"] else: symbol = "[unknown]"
[tip:perf/urgent] perf script python: add Python3 support to check-perf-trace.py
Commit-ID: 57e604b16362273af6a517abaa6cd1133a7fc732 Gitweb: https://git.kernel.org/tip/57e604b16362273af6a517abaa6cd1133a7fc732 Author: Tony Jones AuthorDate: Fri, 1 Mar 2019 17:18:59 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:10:46 -0300 perf script python: add Python3 support to check-perf-trace.py Support both Python 2 and Python 3 in the check-perf-trace.py script. There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of from __future__ implies the minimum supported version of Python2 is now v2.6 Signed-off-by: Tony Jones Cc: Tom Zanussi Link: http://lkml.kernel.org/r/20190302011903.2416-4-to...@suse.de Signed-off-by: Seeteena Thoufeek Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/check-perf-trace.py | 31 +++ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/tools/perf/scripts/python/check-perf-trace.py b/tools/perf/scripts/python/check-perf-trace.py index f4838db3e518..d2c22954800d 100644 --- a/tools/perf/scripts/python/check-perf-trace.py +++ b/tools/perf/scripts/python/check-perf-trace.py @@ -7,6 +7,8 @@ # events, etc. Basically, if this script runs successfully and # displays expected results, Python scripting support should be ok. +from __future__ import print_function + import os import sys @@ -19,7 +21,7 @@ from perf_trace_context import * unhandled = autodict() def trace_begin(): - print "trace_begin" + print("trace_begin") pass def trace_end(): @@ -33,7 +35,7 @@ def irq__softirq_entry(event_name, context, common_cpu, print_uncommon(context) - print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)), + print("vec=%s" % (symbol_str("irq__softirq_entry", "vec", vec))) def kmem__kmalloc(event_name, context, common_cpu, common_secs, common_nsecs, common_pid, common_comm, @@ -44,10 +46,10 @@ def kmem__kmalloc(event_name, context, common_cpu, print_uncommon(context) - print "call_site=%u, ptr=%u, bytes_req=%u, " \ - "bytes_alloc=%u, gfp_flags=%s\n" % \ + print("call_site=%u, ptr=%u, bytes_req=%u, " + "bytes_alloc=%u, gfp_flags=%s" % (call_site, ptr, bytes_req, bytes_alloc, - flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), + flag_str("kmem__kmalloc", "gfp_flags", gfp_flags))) def trace_unhandled(event_name, context, event_fields_dict): try: @@ -56,26 +58,27 @@ def trace_unhandled(event_name, context, event_fields_dict): unhandled[event_name] = 1 def print_header(event_name, cpu, secs, nsecs, pid, comm): - print "%-20s %5u %05u.%09u %8u %-20s " % \ + print("%-20s %5u %05u.%09u %8u %-20s " % (event_name, cpu, secs, nsecs, pid, comm), + end=' ') # print trace fields not included in handler args def print_uncommon(context): - print "common_preempt_count=%d, common_flags=%s, " \ - "common_lock_depth=%d, " % \ + print("common_preempt_count=%d, common_flags=%s, " + "common_lock_depth=%d, " % (common_pc(context), trace_flag_str(common_flags(context)), - common_lock_depth(context)) + common_lock_depth(context))) def print_unhandled(): keys = unhandled.keys() if not keys: return - print "\nunhandled events:\n\n", + print("\nunhandled events:\n") - print "%-40s %10s\n" % ("event", "count"), - print "%-40s %10s\n" % ("", \ - "---"), + print("%-40s %10s" % ("event", "count")) + print("%-40s %10s" % ("", + "---")) for event_name in keys: - print "%-40s %10d\n" % (event_name, unhandled[event_name]) + print("%-40s %10d\n" % (event_name, unhandled[event_name]))
[tip:perf/urgent] perf script python: Add Python3 support to event_analyzing_sample.py
Commit-ID: c253c72e9d6723c8b078beb362f050059ef5de39 Gitweb: https://git.kernel.org/tip/c253c72e9d6723c8b078beb362f050059ef5de39 Author: Tony Jones AuthorDate: Fri, 1 Mar 2019 17:19:00 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:11:11 -0300 perf script python: Add Python3 support to event_analyzing_sample.py Support both Python2 and Python3 in the event_analyzing_sample.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones Cc: Feng Tang Link: http://lkml.kernel.org/r/20190302011903.2416-5-to...@suse.de Signed-off-by: Seeteena Thoufeek Signed-off-by: Arnaldo Carvalho de Melo --- .../perf/scripts/python/event_analyzing_sample.py | 48 +++--- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/tools/perf/scripts/python/event_analyzing_sample.py b/tools/perf/scripts/python/event_analyzing_sample.py index 2ec8915b74c5..aa1e2cfa26a6 100644 --- a/tools/perf/scripts/python/event_analyzing_sample.py +++ b/tools/perf/scripts/python/event_analyzing_sample.py @@ -15,6 +15,8 @@ # for a x86 HW PMU event: PEBS with load latency data. # +from __future__ import print_function + import os import sys import math @@ -37,7 +39,7 @@ con = sqlite3.connect("/dev/shm/perf.db") con.isolation_level = None def trace_begin(): -print "In trace_begin:\n" +print("In trace_begin:\n") # # Will create several tables at the start, pebs_ll is for PEBS data with @@ -76,12 +78,12 @@ def process_event(param_dict): name = param_dict["ev_name"] # Symbol and dso info are not always resolved -if (param_dict.has_key("dso")): +if ("dso" in param_dict): dso = param_dict["dso"] else: dso = "Unknown_dso" -if (param_dict.has_key("symbol")): +if ("symbol" in param_dict): symbol = param_dict["symbol"] else: symbol = "Unknown_symbol" @@ -102,7 +104,7 @@ def insert_db(event): event.ip, event.status, event.dse, event.dla, event.lat)) def trace_end(): -print "In trace_end:\n" +print("In trace_end:\n") # We show the basic info for the 2 type of event classes show_general_events() show_pebs_ll() @@ -123,29 +125,29 @@ def show_general_events(): # Check the total record number in the table count = con.execute("select count(*) from gen_events") for t in count: -print "There is %d records in gen_events table" % t[0] +print("There is %d records in gen_events table" % t[0]) if t[0] == 0: return -print "Statistics about the general events grouped by thread/symbol/dso: \n" +print("Statistics about the general events grouped by thread/symbol/dso: \n") # Group by thread commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)") -print "\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42) +print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42)) for row in commq: - print "%16s %8d %s" % (row[0], row[1], num2sym(row[1])) + print("%16s %8d %s" % (row[0], row[1], num2sym(row[1]))) # Group by symbol -print "\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58) +print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58)) symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)") for row in symbolq: - print "%32s %8d %s" % (row[0], row[1], num2sym(row[1])) + print("%32s %8d %s" % (row[0], row[1], num2sym(row[1]))) # Group by dso -print "\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74) +print("\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74)) dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)") for row in dsoq: - print "%40s %8d %s" % (row[0], row[1], num2sym(row[1])) + print("%40s %8d %s" % (row[0], row[1], num2sym(row[1]))) # # This function just shows the basic info, and we could do more with the @@ -156,35 +158,35 @@ def show_pebs_ll(): count = con.execute("select count(*) from pebs_ll") for t in count: -print "There is %d records in pebs_ll table" % t[0] +print("There is %d records in pebs_ll table" % t[0]) if t[0] == 0: return -print
[tip:perf/urgent] perf script python: Add Python3 support to futex-contention.py
Commit-ID: de2ec16bd438945813198d4de2339a396904c206 Gitweb: https://git.kernel.org/tip/de2ec16bd438945813198d4de2339a396904c206 Author: Tony Jones AuthorDate: Fri, 1 Mar 2019 17:18:58 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:10:43 -0300 perf script python: Add Python3 support to futex-contention.py Support both Python2 and Python3 in the futex-contention.py script There may be differences in the ordering of output lines due to differences in dictionary ordering etc. However the format within lines should be unchanged. The use of 'from __future__' implies the minimum supported Python2 version is now v2.6 Signed-off-by: Tony Jones Link: http://lkml.kernel.org/r/20190302011903.2416-3-to...@suse.de Signed-off-by: Seeteena Thoufeek Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/futex-contention.py | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tools/perf/scripts/python/futex-contention.py b/tools/perf/scripts/python/futex-contention.py index f221c62e0a10..0c4841acf75d 100644 --- a/tools/perf/scripts/python/futex-contention.py +++ b/tools/perf/scripts/python/futex-contention.py @@ -10,6 +10,8 @@ # # Measures futex contention +from __future__ import print_function + import os, sys sys.path.append(os.environ['PERF_EXEC_PATH'] + '/scripts/python/Perf-Trace-Util/lib/Perf/Trace') from Util import * @@ -33,18 +35,18 @@ def syscalls__sys_enter_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, def syscalls__sys_exit_futex(event, ctxt, cpu, s, ns, tid, comm, callchain, nr, ret): - if thread_blocktime.has_key(tid): + if tid in thread_blocktime: elapsed = nsecs(s, ns) - thread_blocktime[tid] add_stats(lock_waits, (tid, thread_thislock[tid]), elapsed) del thread_blocktime[tid] del thread_thislock[tid] def trace_begin(): - print "Press control+C to stop and show the summary" + print("Press control+C to stop and show the summary") def trace_end(): for (tid, lock) in lock_waits: min, max, avg, count = lock_waits[tid, lock] - print "%s[%d] lock %x contended %d times, %d avg ns" % \ - (process_names[tid], tid, lock, count, avg) + print("%s[%d] lock %x contended %d times, %d avg ns" % + (process_names[tid], tid, lock, count, avg))
[tip:perf/urgent] perf script python: Remove mixed indentation
Commit-ID: b504d7f6876515b74c8e27a44ccdb22372616d97 Gitweb: https://git.kernel.org/tip/b504d7f6876515b74c8e27a44ccdb22372616d97 Author: Tony Jones AuthorDate: Fri, 1 Mar 2019 17:18:57 -0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:09:14 -0300 perf script python: Remove mixed indentation Remove mixed indentation in Python scripts. Revert to either all tabs (most common form) or all spaces (4 or 8) depending on what was the intent of the original commit. This is necessary to complete Python3 support as it will flag an error if it encounters mixed indentation. Signed-off-by: Tony Jones Link: http://lkml.kernel.org/r/20190302011903.2416-2-to...@suse.de Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/check-perf-trace.py | 65 +++--- tools/perf/scripts/python/compaction-times.py | 8 +-- .../perf/scripts/python/event_analyzing_sample.py | 6 +- .../perf/scripts/python/failed-syscalls-by-pid.py | 38 ++--- tools/perf/scripts/python/futex-contention.py | 2 +- tools/perf/scripts/python/intel-pt-events.py | 32 +-- tools/perf/scripts/python/mem-phys-addr.py | 7 ++- tools/perf/scripts/python/net_dropmonitor.py | 2 +- tools/perf/scripts/python/netdev-times.py | 12 ++-- tools/perf/scripts/python/sched-migration.py | 6 +- tools/perf/scripts/python/sctop.py | 13 +++-- tools/perf/scripts/python/stackcollapse.py | 2 +- tools/perf/scripts/python/syscall-counts-by-pid.py | 47 tools/perf/scripts/python/syscall-counts.py| 31 +-- 14 files changed, 136 insertions(+), 135 deletions(-) diff --git a/tools/perf/scripts/python/check-perf-trace.py b/tools/perf/scripts/python/check-perf-trace.py index 334599c6032c..f4838db3e518 100644 --- a/tools/perf/scripts/python/check-perf-trace.py +++ b/tools/perf/scripts/python/check-perf-trace.py @@ -23,60 +23,59 @@ def trace_begin(): pass def trace_end(): -print_unhandled() + print_unhandled() def irq__softirq_entry(event_name, context, common_cpu, - common_secs, common_nsecs, common_pid, common_comm, - common_callchain, vec): - print_header(event_name, common_cpu, common_secs, common_nsecs, - common_pid, common_comm) + common_secs, common_nsecs, common_pid, common_comm, + common_callchain, vec): + print_header(event_name, common_cpu, common_secs, common_nsecs, + common_pid, common_comm) -print_uncommon(context) + print_uncommon(context) - print "vec=%s\n" % \ - (symbol_str("irq__softirq_entry", "vec", vec)), + print "vec=%s\n" % (symbol_str("irq__softirq_entry", "vec", vec)), def kmem__kmalloc(event_name, context, common_cpu, - common_secs, common_nsecs, common_pid, common_comm, - common_callchain, call_site, ptr, bytes_req, bytes_alloc, - gfp_flags): - print_header(event_name, common_cpu, common_secs, common_nsecs, - common_pid, common_comm) + common_secs, common_nsecs, common_pid, common_comm, + common_callchain, call_site, ptr, bytes_req, bytes_alloc, + gfp_flags): + print_header(event_name, common_cpu, common_secs, common_nsecs, + common_pid, common_comm) -print_uncommon(context) + print_uncommon(context) - print "call_site=%u, ptr=%u, bytes_req=%u, " \ + print "call_site=%u, ptr=%u, bytes_req=%u, " \ "bytes_alloc=%u, gfp_flags=%s\n" % \ (call_site, ptr, bytes_req, bytes_alloc, - flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)), def trace_unhandled(event_name, context, event_fields_dict): -try: -unhandled[event_name] += 1 -except TypeError: -unhandled[event_name] = 1 + try: + unhandled[event_name] += 1 + except TypeError: + unhandled[event_name] = 1 def print_header(event_name, cpu, secs, nsecs, pid, comm): print "%-20s %5u %05u.%09u %8u %-20s " % \ - (event_name, cpu, secs, nsecs, pid, comm), + (event_name, cpu, secs, nsecs, pid, comm), # print trace fields not included in handler args def print_uncommon(context): -print "common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, " \ -% (common_pc(context), trace_flag_str(common_flags(context)), \ - common_lock_depth(context)) + print "common_preempt_count=%d, common_flags=%s, " \ + "common_lock_depth=%d, " % \ + (common_pc(context), trace_flag_str(common_flags(context)), + common_lock_depth(context)) def print_unhandled(): -keys = unhandled.keys() -if not keys: -return + keys = unhandled.keys() +
[tip:perf/urgent] perf diff: Support --pid/--tid filter options
Commit-ID: c1d3e633e16db3eb64f519c7099171bfcef94b20 Gitweb: https://git.kernel.org/tip/c1d3e633e16db3eb64f519c7099171bfcef94b20 Author: Jin Yao AuthorDate: Tue, 5 Mar 2019 21:05:43 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:06:16 -0300 perf diff: Support --pid/--tid filter options Using the existing symbol_conf.pid_list_str and symbol_conf.tid_list_str logic. For example: perf diff --tid 13965 It'll only diff the samples for thread 13965. Signed-off-by: Jin Yao Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jin Yao Cc: Kan Liang Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1551791143-10334-4-git-send-email-yao@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-diff.txt | 6 ++ tools/perf/builtin-diff.c | 4 2 files changed, 10 insertions(+) diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index 8c2c229faf50..da7809b15cc9 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -168,6 +168,12 @@ OPTIONS CPUs are specified with -: 0-2. Default is to report samples on all CPUs. +--pid=:: + Only diff samples for given process ID (comma separated list). + +--tid=:: + Only diff samples for given thread ID (comma separated list). + COMPARISON -- The comparison is governed by the baseline file. The baseline perf.data diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index dfe6c7606f5a..6e7920793729 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -985,6 +985,10 @@ static const struct option options[] = { OPT_STRING(0, "time", _str, "str", "Time span (time percent or absolute timestamp)"), OPT_STRING(0, "cpu", _list, "cpu", "list of cpus to profile"), + OPT_STRING(0, "pid", _conf.pid_list_str, "pid[,pid...]", + "only consider symbols in these pids"), + OPT_STRING(0, "tid", _conf.tid_list_str, "tid[,tid...]", + "only consider symbols in these tids"), OPT_END() };
[tip:perf/urgent] perf diff: Support --cpu filter option
Commit-ID: daca23b2007595b6a48255ca08c763f56050d1c5 Gitweb: https://git.kernel.org/tip/daca23b2007595b6a48255ca08c763f56050d1c5 Author: Jin Yao AuthorDate: Tue, 5 Mar 2019 21:05:42 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:05:21 -0300 perf diff: Support --cpu filter option To improve 'perf diff', implement a --cpu filter option. Multiple CPUs can be provided as a comma-separated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2. Default is to report samples on all CPUs. For example, perf diff --cpu 0,1 It only diff the samples for CPU0 and CPU1. Signed-off-by: Jin Yao Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jin Yao Cc: Kan Liang Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1551791143-10334-3-git-send-email-yao@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-diff.txt | 5 + tools/perf/builtin-diff.c | 16 2 files changed, 21 insertions(+) diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index 036d65bded51..8c2c229faf50 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -163,6 +163,11 @@ OPTIONS the end of perf.data.old and analyzes the perf.data from the timestamp 3971.150589 to the end of perf.data. +--cpu:: Only diff samples for the list of CPUs provided. Multiple CPUs can + be provided as a comma-separated list with no space: 0,1. Ranges of + CPUs are specified with -: 0-2. Default is to report samples on all + CPUs. + COMPARISON -- The comparison is governed by the baseline file. The baseline perf.data diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 17cd898074c8..dfe6c7606f5a 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -83,6 +83,9 @@ static unsigned int sort_compute = 1; static s64 compute_wdiff_w1; static s64 compute_wdiff_w2; +static const char *cpu_list; +static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS); + enum { COMPUTE_DELTA, COMPUTE_RATIO, @@ -354,6 +357,11 @@ static int diff__process_sample_event(struct perf_tool *tool, return -1; } + if (cpu_list && !test_bit(sample->cpu, cpu_bitmap)) { + ret = 0; + goto out_put; + } + if (!hists__add_entry(hists, , NULL, NULL, NULL, sample, true)) { pr_warning("problem incrementing symbol period, skipping event\n"); goto out_put; @@ -892,6 +900,13 @@ static int __cmd_diff(void) goto out_delete; } + if (cpu_list) { + ret = perf_session__cpu_bitmap(d->session, cpu_list, + cpu_bitmap); + if (ret < 0) + goto out_delete; + } + ret = perf_session__process_events(d->session); if (ret) { pr_err("Failed to process %s\n", d->data.path); @@ -969,6 +984,7 @@ static const struct option options[] = { "How to display percentage of filtered entries", parse_filter_percentage), OPT_STRING(0, "time", _str, "str", "Time span (time percent or absolute timestamp)"), + OPT_STRING(0, "cpu", _list, "cpu", "list of cpus to profile"), OPT_END() };
[tip:perf/urgent] perf diff: Support --time filter option
Commit-ID: 4802138d78caed36cee2a859f77fb2035f230018 Gitweb: https://git.kernel.org/tip/4802138d78caed36cee2a859f77fb2035f230018 Author: Jin Yao AuthorDate: Tue, 5 Mar 2019 21:05:41 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 18:03:23 -0300 perf diff: Support --time filter option To improve 'perf diff', implement a --time filter option to diff the samples within given time window. It supports time percent with multiple time ranges. The time string format is 'a%/n,b%/m,...' or 'a%-b%,c%-%d,...'. For example: Select the second 10% time slice to diff: perf diff --time 10%/2 Select from 0% to 10% time slice to diff: perf diff --time 0%-10% Select the first and the second 10% time slices to diff: perf diff --time 10%/1,10%/2 Select from 0% to 10% and 30% to 40% slices to diff: perf diff --time 0%-10%,30%-40% It also supports analysing samples within a given time window ,. Times have the format seconds.microseconds. If 'start' is not given (i.e., time string is ',x.y') then analysis starts at the beginning of the file. If the stop time is not given (i.e, time string is 'x.y,') then analysis goes to end of file. Time string is 'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps for different perf.data files. For example, we get the timestamp information from perf script. perf script -i perf.data.old mgen 13940 [000] 3946.361400: ... perf script -i perf.data mgen 13940 [000] 3971.150589 ... perf diff --time 3946.361400,:3971.150589, It analyzes the perf.data.old from the timestamp 3946.361400 to the end of perf.data.old and analyzes the perf.data from the timestamp 3971.150589 to the end of perf.data. v4: --- Update abstime_str_dup(), let it return error if strdup is failed, and update __cmd_diff() accordingly. Signed-off-by: Jin Yao Acked-by: Jiri Olsa Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jin Yao Cc: Kan Liang Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1551791143-10334-2-git-send-email-yao@linux.intel.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-diff.txt | 45 ++ tools/perf/builtin-diff.c | 148 + 2 files changed, 179 insertions(+), 14 deletions(-) diff --git a/tools/perf/Documentation/perf-diff.txt b/tools/perf/Documentation/perf-diff.txt index a79c84ae61aa..036d65bded51 100644 --- a/tools/perf/Documentation/perf-diff.txt +++ b/tools/perf/Documentation/perf-diff.txt @@ -118,6 +118,51 @@ OPTIONS sum of shown entries will be always 100%. "absolute" means it retains the original value before and after the filter is applied. +--time:: + Analyze samples within given time window. It supports time + percent with multiple time ranges. Time string is 'a%/n,b%/m,...' + or 'a%-b%,c%-%d,...'. + + For example: + + Select the second 10% time slice to diff: + + perf diff --time 10%/2 + + Select from 0% to 10% time slice to diff: + + perf diff --time 0%-10% + + Select the first and the second 10% time slices to diff: + + perf diff --time 10%/1,10%/2 + + Select from 0% to 10% and 30% to 40% slices to diff: + + perf diff --time 0%-10%,30%-40% + + It also supports analyzing samples within a given time window + ,. Times have the format seconds.microseconds. If 'start' + is not given (i.e., time string is ',x.y') then analysis starts at + the beginning of the file. If stop time is not given (i.e, time + string is 'x.y,') then analysis goes to the end of the file. Time string is + 'a1.b1,c1.d1:a2.b2,c2.d2'. Use ':' to separate timestamps for different + perf.data files. + + For example, we get the timestamp information from 'perf script'. + + perf script -i perf.data.old + mgen 13940 [000] 3946.361400: ... + + perf script -i perf.data + mgen 13940 [000] 3971.150589 ... + + perf diff --time 3946.361400,:3971.150589, + + It analyzes the perf.data.old from the timestamp 3946.361400 to + the end of perf.data.old and analyzes the perf.data from the + timestamp 3971.150589 to the end of perf.data. + COMPARISON -- The comparison is governed by the baseline file. The baseline perf.data diff --git a/tools/perf/builtin-diff.c b/tools/perf/builtin-diff.c index 58fe0e88215c..17cd898074c8 100644 --- a/tools/perf/builtin-diff.c +++ b/tools/perf/builtin-diff.c @@ -19,12 +19,21 @@ #include "util/util.h" #include "util/data.h" #include "util/config.h" +#include "util/time-utils.h" #include #include #include #include +struct perf_diff { + struct perf_tool tool; + const char *time_str; + struct perf_time_interval *ptime_range; + int range_size; + int range_num; +}; + /* Diff
[tip:perf/urgent] perf thread: Generalize function to copy from thread addr space from intel-bts code
Commit-ID: 153259382633ecbbc0af4f3f0b6515757ebe2984 Gitweb: https://git.kernel.org/tip/153259382633ecbbc0af4f3f0b6515757ebe2984 Author: Andi Kleen AuthorDate: Wed, 6 Mar 2019 17:55:35 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 17:55:35 -0300 perf thread: Generalize function to copy from thread addr space from intel-bts code Add a utility function to fetch executable code. Convert one user over to it. There are more places doing that, but they do significantly different actions, so they are not easy to fit into a single library function. Committer changes: . No need to cast around, make 'buf' be a void pointer. . Rename it to thread__memcpy() to reflect the fact it is about copying a chunk of memory from a thread, i.e. from its address space. . No need to have it in a separate object file, move it to thread.[ch] . Check the return of map__load(), the original code didn't do it, but since we're moving this around, check that as well. Signed-off-by: Andi Kleen Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/r/20190305144758.12397-2-a...@firstfloor.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/intel-bts.c | 20 ++-- tools/perf/util/thread.c| 23 +++ tools/perf/util/thread.h| 3 +++ 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/tools/perf/util/intel-bts.c b/tools/perf/util/intel-bts.c index 0c0180c67574..47025bc727e1 100644 --- a/tools/perf/util/intel-bts.c +++ b/tools/perf/util/intel-bts.c @@ -328,35 +328,19 @@ static int intel_bts_get_next_insn(struct intel_bts_queue *btsq, u64 ip) { struct machine *machine = btsq->bts->machine; struct thread *thread; - struct addr_location al; unsigned char buf[INTEL_PT_INSN_BUF_SZ]; ssize_t len; - int x86_64; - uint8_t cpumode; + bool x86_64; int err = -1; - if (machine__kernel_ip(machine, ip)) - cpumode = PERF_RECORD_MISC_KERNEL; - else - cpumode = PERF_RECORD_MISC_USER; - thread = machine__find_thread(machine, -1, btsq->tid); if (!thread) return -1; - if (!thread__find_map(thread, cpumode, ip, ) || !al.map->dso) - goto out_put; - - len = dso__data_read_addr(al.map->dso, al.map, machine, ip, buf, - INTEL_PT_INSN_BUF_SZ); + len = thread__memcpy(thread, machine, buf, ip, INTEL_PT_INSN_BUF_SZ, _64); if (len <= 0) goto out_put; - /* Load maps to ensure dso->is_64_bit has been updated */ - map__load(al.map); - - x86_64 = al.map->dso->is_64_bit; - if (intel_pt_get_insn(buf, len, x86_64, >intel_pt_insn)) goto out_put; diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c index 4c179fef442d..50678d318185 100644 --- a/tools/perf/util/thread.c +++ b/tools/perf/util/thread.c @@ -12,6 +12,7 @@ #include "debug.h" #include "namespaces.h" #include "comm.h" +#include "map.h" #include "symbol.h" #include "unwind.h" @@ -393,3 +394,25 @@ struct thread *thread__main_thread(struct machine *machine, struct thread *threa return machine__find_thread(machine, thread->pid_, thread->pid_); } + +int thread__memcpy(struct thread *thread, struct machine *machine, + void *buf, u64 ip, int len, bool *is64bit) +{ + u8 cpumode = PERF_RECORD_MISC_USER; + struct addr_location al; + long offset; + + if (machine__kernel_ip(machine, ip)) + cpumode = PERF_RECORD_MISC_KERNEL; + + if (!thread__find_map(thread, cpumode, ip, ) || !al.map->dso || + al.map->dso->data.status == DSO_DATA_STATUS_ERROR || + map__load(al.map) < 0) + return -1; + + offset = al.map->map_ip(al.map, ip); + if (is64bit) + *is64bit = al.map->dso->is_64_bit; + + return dso__data_read_offset(al.map->dso, machine, offset, buf, len); +} diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h index 8276ffeec556..cf8375c017a0 100644 --- a/tools/perf/util/thread.h +++ b/tools/perf/util/thread.h @@ -113,6 +113,9 @@ struct symbol *thread__find_symbol_fb(struct thread *thread, u8 cpumode, void thread__find_cpumode_addr_location(struct thread *thread, u64 addr, struct addr_location *al); +int thread__memcpy(struct thread *thread, struct machine *machine, + void *buf, u64 ip, int len, bool *is64bit); + static inline void *thread__priv(struct thread *thread) { return thread->priv;
[tip:perf/urgent] perf annotate: Calculate the max instruction name, align column to that
Commit-ID: bc3bb795345891509b4a3cbff824cbef8c130f20 Gitweb: https://git.kernel.org/tip/bc3bb795345891509b4a3cbff824cbef8c130f20 Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 6 Mar 2019 16:40:15 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 16:40:15 -0300 perf annotate: Calculate the max instruction name, align column to that We were hardcoding '6' as the max instruction name, and we have lots that are longer than that, see the diff from two 'P' printed TUI annotations for a libc function that uses instructions with long names, such as 'vpmovmskb' with its 9 chars: --- __strcmp_avx2.annotation.before 2019-03-06 16:31:39.368020425 -0300 +++ __strcmp_avx2.annotation 2019-03-06 16:32:12.079450508 -0300 @@ -2,284 +2,284 @@ Event: cycles:ppp Percentendbr64 - 0.10 mov%edi,%eax + 0.10 mov%edi,%eax - xor%edx,%edx + xor%edx,%edx - 3.54 vpxor %ymm7,%ymm7,%ymm7 + 3.54 vpxor %ymm7,%ymm7,%ymm7 - or %esi,%eax + or %esi,%eax - and$0xfff,%eax + and$0xfff,%eax - cmp$0xf80,%eax + cmp$0xf80,%eax - ↓ jg 370 + ↓ jg 370 - 27.07 vmovdqu (%rdi),%ymm1 + 27.07 vmovdqu(%rdi),%ymm1 - 7.97 vpcmpeqb (%rsi),%ymm1,%ymm0 + 7.97 vpcmpeqb (%rsi),%ymm1,%ymm0 - 2.15 vpminub %ymm1,%ymm0,%ymm0 + 2.15 vpminub%ymm1,%ymm0,%ymm0 - 4.09 vpcmpeqb %ymm7,%ymm0,%ymm0 + 4.09 vpcmpeqb %ymm7,%ymm0,%ymm0 - 0.43 vpmovmskb %ymm0,%ecx + 0.43 vpmovmskb %ymm0,%ecx - 1.53 test %ecx,%ecx + 1.53 test %ecx,%ecx - ↓ je b0 + ↓ je b0 - 5.26 tzcnt %ecx,%edx + 5.26 tzcnt %ecx,%edx - 18.40 movzbl (%rdi,%rdx,1),%eax + 18.40 movzbl (%rdi,%rdx,1),%eax - 7.09 movzbl (%rsi,%rdx,1),%edx + 7.09 movzbl (%rsi,%rdx,1),%edx - 3.34 sub%edx,%eax + 3.34 sub%edx,%eax 2.37 vzeroupper ← retq nop - 50: tzcnt %ecx,%edx + 50: tzcnt %ecx,%edx - movzbl 0x20(%rdi,%rdx,1),%eax + movzbl 0x20(%rdi,%rdx,1),%eax - movzbl 0x20(%rsi,%rdx,1),%edx + movzbl 0x20(%rsi,%rdx,1),%edx - sub%edx,%eax + sub%edx,%eax vzeroupper ← retq - data16 nopw %cs:0x0(%rax,%rax,1) + data16 nopw %cs:0x0(%rax,%rax,1) Reported-by: Travis Downs LPU-Reference: caobgo4z1kfmweom6et0cnx5z6dwsg2pqbavrn1mhvpjmxhr...@mail.gmail.com Cc: Adrian Hunter Cc: Jiri Olsa Cc: Namhyung Kim Link: https://lkml.kernel.org/n/tip-89wsdd9h9g6bvq52sgp6d...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/arch/arm64/annotate/instructions.c | 2 +- tools/perf/arch/s390/annotate/instructions.c | 2 +- tools/perf/util/annotate.c| 74 +-- tools/perf/util/annotate.h| 7 +-- 4 files changed, 52 insertions(+), 33 deletions(-) diff --git a/tools/perf/arch/arm64/annotate/instructions.c b/tools/perf/arch/arm64/annotate/instructions.c index 76c6345a57d5..8f70a1b282df 100644 --- a/tools/perf/arch/arm64/annotate/instructions.c +++ b/tools/perf/arch/arm64/annotate/instructions.c @@ -58,7 +58,7 @@ out_free_source: } static int mov__scnprintf(struct ins *ins, char *bf, size_t size, - struct ins_operands *ops); + struct ins_operands *ops, int max_ins_name); static struct ins_ops arm64_mov_ops = { .parse = arm64_mov__parse, diff --git a/tools/perf/arch/s390/annotate/instructions.c b/tools/perf/arch/s390/annotate/instructions.c index de0dd66dbb48..89bb8f2c54ce 100644 --- a/tools/perf/arch/s390/annotate/instructions.c +++ b/tools/perf/arch/s390/annotate/instructions.c @@ -46,7 +46,7 @@ static int s390_call__parse(struct arch *arch, struct ins_operands *ops, } static int call__scnprintf(struct ins *ins, char *bf, size_t size, - struct ins_operands *ops); + struct ins_operands *ops, int max_ins_name); static struct ins_ops s390_call_ops = { .parse = s390_call__parse, diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 11a8a447a3af..5f6dbbf5d749 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -198,18 +198,18 @@ static void ins__delete(struct ins_operands *ops) } static int ins__raw_scnprintf(struct ins *ins, char *bf, size_t size, - struct ins_operands *ops) +
[tip:perf/urgent] perf clang: Remove needless extra semicolon
Commit-ID: a53837a5458c5b84588dfa3fa510c6a29b7bd4d7 Gitweb: https://git.kernel.org/tip/a53837a5458c5b84588dfa3fa510c6a29b7bd4d7 Author: Yang Wei AuthorDate: Mon, 4 Mar 2019 22:36:14 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 09:47:48 -0300 perf clang: Remove needless extra semicolon Delete a superfluous semicolon in getBPFObjectFromModule(). Signed-off-by: Yang Wei Cc: Alexander Shishkin Cc: Jiri Olsa Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Yang Wei Link: http://lkml.kernel.org/r/1551710174-3349-1-git-send-email-albin_y...@163.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/c++/clang.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/util/c++/clang.cpp b/tools/perf/util/c++/clang.cpp index 39c0004f2886..fc361c3f8570 100644 --- a/tools/perf/util/c++/clang.cpp +++ b/tools/perf/util/c++/clang.cpp @@ -156,7 +156,7 @@ getBPFObjectFromModule(llvm::Module *Module) #endif if (NotAdded) { llvm::errs() << "TargetMachine can't emit a file of this type\n"; - return std::unique_ptr>(nullptr);; + return std::unique_ptr>(nullptr); } PM.run(*Module);
[tip:perf/urgent] perf bpf: Automatically add BTF ELF markers
Commit-ID: 3163613c5bc805dadac8ea157648eefd46747cae Gitweb: https://git.kernel.org/tip/3163613c5bc805dadac8ea157648eefd46747cae Author: Arnaldo Carvalho de Melo AuthorDate: Fri, 1 Mar 2019 16:09:31 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 6 Mar 2019 09:45:37 -0300 perf bpf: Automatically add BTF ELF markers The libbpf loader expects that some __btf_map_ structs be in place with the keys and values types of maps so that one can store the struct definitions and have them sent to the kernel via sys_bpf(fd, cmd = BTF_LOAD) and then later be retrievable via sys_bpf(fd, cmd = BPF_OBJ_GET_INFO_BY_FD) for use by tools such as 'bpftool map dump id MAP_ID'. Since we already have this for defining maps in 'perf trace' BPF events: bpf_map(name, _type, type_key, type_val, _max_entries) As used in the tools/perf/examples/bpf/augmented_raw_syscalls.c: --- 8< --- struct syscall { boolenabled; }; bpf_map(syscalls, ARRAY, int, struct syscall, 512); --- 8< --- All we need is to get all that already available info, piggyback on the 'bpf_map' define in tools/perf/include/bpf/bpf.h, that is included by 'perf trace' BPF programs and do that without requiring changes to the BPF programs already defining maps using 'bpf_map()'. So this is what we have before this patch: 1) With this in ~/.perfconfig to dump .c events as .o, aka save a copy so that we can use the .o later as a pre-compiled BPF bytecode: # grep '\[llvm\]' -A2 ~/.perfconfig [llvm] dump-obj = true clang-opt = -g # # clang --version clang version 9.0.0 (https://git.llvm.org/git/clang.git/ 7906282d3afec5dfdc2b27943fd6c0309086c507) (https://git.llvm.org/git/llvm.git/ a1b5de1ff8ae8bc79dc8e86e1f82565229bd0500) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /opt/llvm/bin 2) Note the -g there so that we get clang to generate debuginfo, and since the target is 'bpf' it will generate the BTF info in this clang version (9.0). 3) Run a simple 'perf record' specifiying as an event the augmented_raw_syscalls.c source code: # perf record -e /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.c sleep 1 LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.025 MB perf.data ] # file /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o: ELF 64-bit LSB relocatable, eBPF, version 1 (SYSV), with debug_info, not stripped 4) Look at the BTF structs encoded in it: # pahole -F btf --sizes /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o syscall_enter_args64 0 augmented_filename264 0 syscall 1 0 syscall_exit_args 24 0 bpf_map 28 0 # # pahole -F btf -C syscalls /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o # pahole -F btf -C syscall /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o struct syscall { bool enabled; /* 0 1 */ /* size: 1, cachelines: 1, members: 1 */ /* last cacheline: 1 bytes */ }; # 5) Ok, with just this we don't have the markers expected by the libbpf loader and when we run with this BPF bytecode, because we have: # grep '\[trace\]' -A1 ~/.perfconfig [trace] add_events = /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o # 6) Lets do a 'perf trace' system wide session using this BPF program: # perf trace -e *mmsg,open* Cache2 I/O/6885 openat(AT_FDCWD, "/home/acme/.cache/mozilla/firefox/ina67tev.default/cache2/entries/BA220AB2914006A7AE96D27BE6EA13DD77519FCA", O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR) = 106 Cache2 I/O/6885 openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY) = 121 Cache2 I/O/6885 openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY) = 121 Cache2 I/O/6885 openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY) = 121 Cache2 I/O/6885 openat(AT_FDCWD, "/proc/self/mountinfo", O_RDONLY) = 121 DNS Res~ver #3/23340 openat(AT_FDCWD, "/etc/hosts", O_RDONLY|O_CLOEXEC) = 106 DNS Res~ver #3/23340 sendmmsg(106, 0x7f252f1fcaf0, 2, MSG_NOSIGNAL) = 2 Cache2 I/O/6885 openat(AT_FDCWD, "/home/acme/.cache/mozilla/firefox/ina67tev.default/cache2/entries/BA220AB2914006A7AE96D27BE6EA13DD77519FCA", O_RDWR) = 106 lighttpd/18915 openat(AT_FDCWD, "/proc/loadavg", O_RDONLY) = 12 7) While it runs lets see the maps that 'perf trace' + libbpf's BPF loader loaded into the kernel via sys_bpf(fd, BPF_BTF_LOAD, ...): # bpftool map list | tail -6 149: perf_event_array name __augmented_sys flags 0x0 key 4B value 4B max_entries 8 memlock 4096B 150: array name syscalls flags 0x0 key 4B value 1B max_entries 512 memlock 8192B 151: hash name
[tip:perf/urgent] perf beauty msg_flags: Add missing %s lost when adding prefix suppression logic
Commit-ID: c3b81a500f35241a4c16febe0a015e572cf2c492 Gitweb: https://git.kernel.org/tip/c3b81a500f35241a4c16febe0a015e572cf2c492 Author: Arnaldo Carvalho de Melo AuthorDate: Fri, 1 Mar 2019 15:45:35 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 15:45:35 -0300 perf beauty msg_flags: Add missing %s lost when adding prefix suppression logic When the prefix suppresion/enabling logic was added, I forgot to add an extra %, which ended up chopping off the strings: Before: # perf trace -e *mmsg --map-dump syscalls [299] = 1, [307] = 1, DNS Res~ver #3/14587 sendmmsg(106, 0x7f252b0fcaf0, 2, MSG_) = 2 chronyd/1053 recvmmsg(4, 0x558542ca5740, 4, MSG_, NULL) = 1 DNS Res~ver #2/14445 sendmmsg(106, 0x7f252ab09af0, 2, MSG_) = 2 DNS Res~ver #2/1 sendmmsg(146, 0x7f2521a7aaf0, 2, MSG_) = 2 DNS Res~ver #2/14445 sendmmsg(106, 0x7f252ab09af0, 2, MSG_) = 2 DNS Res~ver #3/14587 sendmmsg(148, 0x7f252b0fcaf0, 2, MSG_) = 2 DNS Res~ver #2/1 sendmmsg(146, 0x7f2521a7aaf0, 2, MSG_) = 2 ^C# After: # perf trace -e *mmsg --map-dump syscalls [299] = 1, [307] = 1, NetworkManager/17467 sendmmsg(22, 0x7f28927f9bb0, 2, MSG_NOSIGNAL) = 2 pool/17478 sendmmsg(10, 0x7f2769f95e90, 2, MSG_NOSIGNAL) = 2 DNS Res~ver #3/14587 sendmmsg(121, 0x7f252b0fcaf0, 2, MSG_NOSIGNAL) = 2 chronyd/1053 recvmmsg(4, 0x558542ca5740, 4, MSG_DONTWAIT, NULL) = 1 Socket Thread/17433 sendmmsg(121, 0x7f252668baf0, 2, MSG_NOSIGNAL) = 2 ^C# Cc: Adrian Hunter Cc: Jiri Olsa Cc: Luis Cláudio Gonçalves Cc: Namhyung Kim Cc: Wang Nan Fixes: c65c83ffe904 ("perf trace: Allow asking for not suppressing common string prefixes") Link: https://lkml.kernel.org/n/tip-t2eu1rqx710k6jr4814ml...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/trace/beauty/msg_flags.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/trace/beauty/msg_flags.c b/tools/perf/trace/beauty/msg_flags.c index d66c66315987..ea68db08b8e7 100644 --- a/tools/perf/trace/beauty/msg_flags.c +++ b/tools/perf/trace/beauty/msg_flags.c @@ -29,7 +29,7 @@ static size_t syscall_arg__scnprintf_msg_flags(char *bf, size_t size, return scnprintf(bf, size, "NONE"); #defineP_MSG_FLAG(n) \ if (flags & MSG_##n) { \ - printed += scnprintf(bf + printed, size - printed, "%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ + printed += scnprintf(bf + printed, size - printed, "%s%s%s", printed ? "|" : "", show_prefix ? prefix : "", #n); \ flags &= ~MSG_##n; \ }
[tip:perf/urgent] perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase
Commit-ID: 254c0d820b86d7712e03750c58ab104e06e3655d Gitweb: https://git.kernel.org/tip/254c0d820b86d7712e03750c58ab104e06e3655d Author: Adrian Hunter AuthorDate: Thu, 28 Feb 2019 15:00:30 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 14:56:17 -0300 perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase Factor out a base class CallGraphModelBase from CallGraphModel, so that CallGraphModelBase can be reused. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: https://lkml.kernel.org/n/tip-76eybebzjwvgnadkm2ouf...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 100 +-- 1 file changed, 55 insertions(+), 45 deletions(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index b2a22525549d..c4a2134d85f5 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -558,26 +558,12 @@ class CallGraphRootItem(CallGraphLevelItemBase): self.child_items.append(child_item) self.child_count += 1 -# Context-sensitive call graph data model +# Context-sensitive call graph data model base -class CallGraphModel(TreeModel): +class CallGraphModelBase(TreeModel): def __init__(self, glb, parent=None): - super(CallGraphModel, self).__init__(glb, parent) - - def GetRoot(self): - return CallGraphRootItem(self.glb) - - def columnCount(self, parent=None): - return 7 - - def columnHeader(self, column): - headers = ["Call Path", "Object", "Count ", "Time (ns) ", "Time (%) ", "Branch Count ", "Branch Count (%) "] - return headers[column] - - def columnAlignment(self, column): - alignment = [ Qt.AlignLeft, Qt.AlignLeft, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight ] - return alignment[column] + super(CallGraphModelBase, self).__init__(glb, parent) def FindSelect(self, value, pattern, query): if pattern: @@ -597,34 +583,7 @@ class CallGraphModel(TreeModel): match = " GLOB '" + str(value) + "'" else: match = " = '" + str(value) + "'" - QueryExec(query, "SELECT call_path_id, comm_id, thread_id" - " FROM calls" - " INNER JOIN call_paths ON calls.call_path_id = call_paths.id" - " INNER JOIN symbols ON call_paths.symbol_id = symbols.id" - " WHERE symbols.name" + match + - " GROUP BY comm_id, thread_id, call_path_id" - " ORDER BY comm_id, thread_id, call_path_id") - - def FindPath(self, query): - # Turn the query result into a list of ids that the tree view can walk - # to open the tree at the right place. - ids = [] - parent_id = query.value(0) - while parent_id: - ids.insert(0, parent_id) - q2 = QSqlQuery(self.glb.db) - QueryExec(q2, "SELECT parent_id" - " FROM call_paths" - " WHERE id = " + str(parent_id)) - if not q2.next(): - break - parent_id = q2.value(0) - # The call path root is not used - if ids[0] == 1: - del ids[0] - ids.insert(0, query.value(2)) - ids.insert(0, query.value(1)) - return ids + self.DoFindSelect(query, match) def Found(self, query, found): if found: @@ -678,6 +637,57 @@ class CallGraphModel(TreeModel): def FindDone(self, thread, callback, ids): callback(ids) +# Context-sensitive call graph data model + +class CallGraphModel(CallGraphModelBase): + + def __init__(self, glb, parent=None): + super(CallGraphModel, self).__init__(glb, parent) + + def GetRoot(self): + return CallGraphRootItem(self.glb) + + def columnCount(self, parent=None): + return 7 + + def columnHeader(self, column): + headers = ["Call Path", "Object", "Count ", "Time (ns) ", "Time (%) ", "Branch Count ", "Branch Count (%) "] + return headers[column] + + def columnAlignment(self, column): + alignment = [ Qt.AlignLeft, Qt.AlignLeft, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight, Qt.AlignRight ] + return
[tip:perf/urgent] perf scripts python: exported-sql-viewer.py: Add call tree
Commit-ID: ae8b887c00d3fe4ca8c2cba16ae452b5df4c19e2 Gitweb: https://git.kernel.org/tip/ae8b887c00d3fe4ca8c2cba16ae452b5df4c19e2 Author: Adrian Hunter AuthorDate: Thu, 28 Feb 2019 15:00:31 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 15:04:16 -0300 perf scripts python: exported-sql-viewer.py: Add call tree Add a new report to display a call tree. The Call Tree report is very similar to the Context-Sensitive Call Graph, but the data is not aggregated. Also the 'Count' column, which would be always 1, is replaced by the 'Call Time'. Committer testing: $ cat simple-retpoline.c /* https://lkml.kernel.org/r/20190109091835.5570-6-adrian.hun...@intel.com $ gcc -ggdb3 -Wall -Wextra -O2 -o simple-retpoline simple-retpoline.c $ objdump -d simple-retpoline */ __attribute__((noinline)) int bar(void) { return -1; } int foo(void) { return bar() + 1; } __attribute__((indirect_branch("thunk"))) int main() { int (*volatile fn)(void) = foo; fn(); return fn(); } $ $ perf record -o simple-retpoline.perf.data -e intel_pt/cyc/u ./simple-retpoline $ perf script -i simple-retpoline.perf.data --itrace=be -s ~acme/libexec/perf-core/scripts/python/export-to-sqlite.py simple-retpoline.db branches calls $ python ~acme/libexec/perf-core/scripts/python/exported-sql-viewer.py simple-retpoline.db And in the GUI select: "Reports" "Call Tree" Call Path | Object | Call Time (ns) | Time (ns) | Time (%) | Branch Count | Brach Count (%) | > simple-retpolin > PID:TID > _startld-2.28.so 2193855505777 156267 100.0 10602 100.0 unknown unknown 21938555060102276 1.5 10.0 > _dl_start ld-2.28.so 2193855508286 137047 87.7 10088 95.2 > _dl_initld-2.28.so 21938556454449142 5.9 3263.1 > _start simple-retpoline 21938556545877457 4.8 1821.7 > __libc_start_main > mainsimple-retpoline 2193855657493 32 0.5 126.7 > foo simple-retpoline 2193855657493 14 43.8 5 41.7 Signed-off-by: Adrian Hunter Tested-by: Arnaldo Carvalho de Melo Cc: Jiri Olsa Link: https://lkml.kernel.org/n/tip-enf0w96gqzfpv4fi16pw9...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 195 +-- 1 file changed, 186 insertions(+), 9 deletions(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index c4a2134d85f5..afec9479ca7f 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -688,6 +688,150 @@ class CallGraphModel(CallGraphModelBase): ids.insert(0, query.value(1)) return ids +# Call tree data model level 2+ item base + +class CallTreeLevelTwoPlusItemBase(CallGraphLevelItemBase): + + def __init__(self, glb, row, comm_id, thread_id, calls_id, time, branch_count, parent_item): + super(CallTreeLevelTwoPlusItemBase, self).__init__(glb, row, parent_item) + self.comm_id = comm_id + self.thread_id = thread_id + self.calls_id = calls_id + self.branch_count = branch_count + self.time = time + + def Select(self): + self.query_done = True; + if self.calls_id == 0: + comm_thread = " AND comm_id = " + str(self.comm_id) + " AND thread_id = " + str(self.thread_id) + else: + comm_thread = "" + query = QSqlQuery(self.glb.db) + QueryExec(query, "SELECT calls.id, name, short_name, call_time, return_time - call_time, branch_count" + " FROM calls" + " INNER JOIN call_paths ON calls.call_path_id = call_paths.id" + " INNER JOIN symbols ON call_paths.symbol_id = symbols.id" + " INNER JOIN dsos ON symbols.dso_id = dsos.id" + " WHERE calls.parent_id = " + str(self.calls_id) + comm_thread + + " ORDER BY call_time, calls.id") + while query.next(): + child_item = CallTreeLevelThreeItem(self.glb, self.child_count, self.comm_id, self.thread_id, query.value(0), query.value(1), query.value(2), query.value(3), int(query.value(4)), int(query.value(5)),
Re: [GIT PULL] Kselftest update for Linux 5.1-rc1
The pull request you sent on Wed, 6 Mar 2019 14:04:20 -0700: > git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest > tags/linux-kselftest-5.1-rc1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/a448c643bc49f14bb3aae68ee7085b4c7f6207d8 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] gcc-plugin updates for v5.1-rc1
The pull request you sent on Mon, 4 Mar 2019 09:48:02 -0800: > https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git > tags/gcc-plugins-v5.1-rc1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/2bb995405fe52dd893db57456556e8dc4fce35a7 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] leaking_addresses: changes for v5.1-rc1
The pull request you sent on Thu, 7 Mar 2019 13:25:22 +1100: > ssh://g...@gitolite.kernel.org/pub/scm/linux/kernel/git/tobin/leaks.git > tags/leaks-5.1-rc1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/99b25a7fc6150d613be8eab71a47e6c0fcc8d7c5 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] pstore updates for v5.1-rc1
The pull request you sent on Mon, 4 Mar 2019 09:27:51 -0800: > https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git > tags/pstore-v5.1-rc1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/a39f009acefd85d3e36bcae828a4e67c9dce9684 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] Documentation for 5.1
The pull request you sent on Thu, 7 Mar 2019 15:18:20 -0700: > git://git.lwn.net/linux.git tags/docs-5.1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/1a29e857507046e413ca7a4a7c9cd32fed9ea255 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] printk for 5.1
The pull request you sent on Wed, 6 Mar 2019 15:44:45 +0100: > git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk > tags/printk-for-5.1 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/c4703acd6d4a58dc4b31ad2a8f8b14becb898d25 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT][PULL] smb3 fixes
The pull request you sent on Fri, 8 Mar 2019 10:54:02 -0600: > git://git.samba.org/sfrench/cifs-2.6.git tags/5.1-rc-smb3-fixes has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/e519a8c2c3431fbc27e453ff73f5b51df5afe6b5 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
Re: [GIT PULL] fscrypt updates for v5.1
The pull request you sent on Mon, 4 Mar 2019 13:47:22 -0800: > git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt.git tags/fscrypt-for-linus has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/d1cae94871330cb9f5fdcea34529abf7917e682e Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
[tip:perf/urgent] perf scripts python: exported-sql-viewer.py: Improve TreeModel abstraction
Commit-ID: a448ba232a5f0176c226df1bab8877ec06a7c771 Gitweb: https://git.kernel.org/tip/a448ba232a5f0176c226df1bab8877ec06a7c771 Author: Adrian Hunter AuthorDate: Thu, 28 Feb 2019 15:00:29 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 14:55:32 -0300 perf scripts python: exported-sql-viewer.py: Improve TreeModel abstraction Instead of passing the tree root, get it from a method that can be implemented in any derived class. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: https://lkml.kernel.org/n/tip-ovcv28bg4mt9swk36ypdy...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 17 +++-- 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index df854f0a69f0..b2a22525549d 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -167,9 +167,10 @@ class Thread(QThread): class TreeModel(QAbstractItemModel): - def __init__(self, root, parent=None): + def __init__(self, glb, parent=None): super(TreeModel, self).__init__(parent) - self.root = root + self.glb = glb + self.root = self.GetRoot() self.last_row_read = 0 def Item(self, parent): @@ -562,8 +563,10 @@ class CallGraphRootItem(CallGraphLevelItemBase): class CallGraphModel(TreeModel): def __init__(self, glb, parent=None): - super(CallGraphModel, self).__init__(CallGraphRootItem(glb), parent) - self.glb = glb + super(CallGraphModel, self).__init__(glb, parent) + + def GetRoot(self): + return CallGraphRootItem(self.glb) def columnCount(self, parent=None): return 7 @@ -1339,8 +1342,7 @@ class BranchModel(TreeModel): progress = Signal(object) def __init__(self, glb, event_id, where_clause, parent=None): - super(BranchModel, self).__init__(BranchRootItem(), parent) - self.glb = glb + super(BranchModel, self).__init__(glb, parent) self.event_id = event_id self.more = True self.populated = 0 @@ -1364,6 +1366,9 @@ class BranchModel(TreeModel): self.fetcher.done.connect(self.Update) self.fetcher.Fetch(glb_chunk_sz) + def GetRoot(self): + return BranchRootItem() + def columnCount(self, parent=None): return 8
[tip:perf/urgent] perf scripts python: exported-sql-viewer.py: Factor out TreeWindowBase
Commit-ID: a731cc4c990a90d9d42a2081ca93fb4310680ae2 Gitweb: https://git.kernel.org/tip/a731cc4c990a90d9d42a2081ca93fb4310680ae2 Author: Adrian Hunter AuthorDate: Thu, 28 Feb 2019 15:00:28 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 14:54:39 -0300 perf scripts python: exported-sql-viewer.py: Factor out TreeWindowBase Factor out a base class TreeWindowBase from CallGraphWindow, so that TreeWindowBase can be reused. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: https://lkml.kernel.org/n/tip-ifirw0c0mhkwxg6l12lk6...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/exported-sql-viewer.py | 50 +++- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/tools/perf/scripts/python/exported-sql-viewer.py b/tools/perf/scripts/python/exported-sql-viewer.py index 09ce73b07d35..df854f0a69f0 100755 --- a/tools/perf/scripts/python/exported-sql-viewer.py +++ b/tools/perf/scripts/python/exported-sql-viewer.py @@ -693,28 +693,16 @@ class VBox(): def Widget(self): return self.vbox -# Context-sensitive call graph window - -class CallGraphWindow(QMdiSubWindow): - - def __init__(self, glb, parent=None): - super(CallGraphWindow, self).__init__(parent) +# Tree window base - self.model = LookupCreateModel("Context-Sensitive Call Graph", lambda x=glb: CallGraphModel(x)) +class TreeWindowBase(QMdiSubWindow): - self.view = QTreeView() - self.view.setModel(self.model) - - for c, w in ((0, 250), (1, 100), (2, 60), (3, 70), (4, 70), (5, 100)): - self.view.setColumnWidth(c, w) - - self.find_bar = FindBar(self, self) - - self.vbox = VBox(self.view, self.find_bar.Widget()) - - self.setWidget(self.vbox.Widget()) + def __init__(self, parent=None): + super(TreeWindowBase, self).__init__(parent) - AddSubWindow(glb.mainwindow.mdi_area, self, "Context-Sensitive Call Graph") + self.model = None + self.view = None + self.find_bar = None def DisplayFound(self, ids): if not len(ids): @@ -747,6 +735,30 @@ class CallGraphWindow(QMdiSubWindow): if not found: self.find_bar.NotFound() + +# Context-sensitive call graph window + +class CallGraphWindow(TreeWindowBase): + + def __init__(self, glb, parent=None): + super(CallGraphWindow, self).__init__(parent) + + self.model = LookupCreateModel("Context-Sensitive Call Graph", lambda x=glb: CallGraphModel(x)) + + self.view = QTreeView() + self.view.setModel(self.model) + + for c, w in ((0, 250), (1, 100), (2, 60), (3, 70), (4, 70), (5, 100)): + self.view.setColumnWidth(c, w) + + self.find_bar = FindBar(self, self) + + self.vbox = VBox(self.view, self.find_bar.Widget()) + + self.setWidget(self.vbox.Widget()) + + AddSubWindow(glb.mainwindow.mdi_area, self, "Context-Sensitive Call Graph") + # Child data item finder class ChildDataItemFinder():
[tip:perf/urgent] perf scripts python: export-to-postgresql.py: Fix invalid input syntax for integer error
Commit-ID: 07c5ebead85f507271fb8e2a8b5814e486702518 Gitweb: https://git.kernel.org/tip/07c5ebead85f507271fb8e2a8b5814e486702518 Author: Adrian Hunter AuthorDate: Thu, 28 Feb 2019 15:00:26 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 14:53:12 -0300 perf scripts python: export-to-postgresql.py: Fix invalid input syntax for integer error Fix SQL query error "invalid input syntax for integer": Traceback (most recent call last): File "tools/perf/scripts/python/export-to-postgresql.py", line 465, in do_query(query, 'CREATE VIEW calls_view AS ' File "tools/perf/scripts/python/export-to-postgresql.py", line 274, in do_query raise Exception("Query failed: " + q.lastError().text()) Exception: Query failed: ERROR: invalid input syntax for integer: "" LINE 1: ...ch_count,call_id,return_id,CASE WHEN flags=0 THEN '' WHEN fl... ^ (22P02) QPSQL: Unable to create query Error running python script tools/perf/scripts/python/export-to-postgresql.py Signed-off-by: Adrian Hunter Cc: Jiri Olsa Fixes: f08046cb3082 ("perf thread-stack: Represent jmps to the start of a different symbol") Link: https://lkml.kernel.org/n/tip-strfpdozrvg7bi1xzrivx...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/export-to-postgresql.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py index 30130213da7e..6358522a69f6 100644 --- a/tools/perf/scripts/python/export-to-postgresql.py +++ b/tools/perf/scripts/python/export-to-postgresql.py @@ -478,7 +478,7 @@ if perf_db_export_calls: 'branch_count,' 'call_id,' 'return_id,' - 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE flags END AS flags,' + 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE CAST ( flags AS VARCHAR(6) ) END AS flags,' 'parent_call_path_id' ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
[tip:perf/urgent] perf scripts python: export-to-postgresql.py: Export calls parent_id
Commit-ID: febce6dc1f5167e683d6e3c3d0f6ab7f98201ea8 Gitweb: https://git.kernel.org/tip/febce6dc1f5167e683d6e3c3d0f6ab7f98201ea8 Author: Adrian Hunter AuthorDate: Thu, 28 Feb 2019 15:00:27 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 1 Mar 2019 14:53:33 -0300 perf scripts python: export-to-postgresql.py: Export calls parent_id Export to the 'calls' table the newly created 'parent_id' and create an index for it. Signed-off-by: Adrian Hunter Cc: Jiri Olsa Link: https://lkml.kernel.org/n/tip-eybd6fnk6j9r7g643lsid...@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/scripts/python/export-to-postgresql.py | 14 +- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/perf/scripts/python/export-to-postgresql.py b/tools/perf/scripts/python/export-to-postgresql.py index 6358522a69f6..390a351d15ea 100644 --- a/tools/perf/scripts/python/export-to-postgresql.py +++ b/tools/perf/scripts/python/export-to-postgresql.py @@ -394,7 +394,8 @@ if perf_db_export_calls: 'call_idbigint,' 'return_id bigint,' 'parent_call_path_idbigint,' - 'flags integer)') + 'flags integer,' + 'parent_id bigint)') do_query(query, 'CREATE VIEW machines_view AS ' 'SELECT ' @@ -479,7 +480,8 @@ if perf_db_export_calls: 'call_id,' 'return_id,' 'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE CAST ( flags AS VARCHAR(6) ) END AS flags,' - 'parent_call_path_id' + 'parent_call_path_id,' + 'calls.parent_id' ' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id') do_query(query, 'CREATE VIEW samples_view AS ' @@ -575,6 +577,7 @@ def trace_begin(): sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) if perf_db_export_calls or perf_db_export_callchains: call_path_table(0, 0, 0, 0) + call_return_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) unhandled_count = 0 @@ -657,6 +660,7 @@ def trace_end(): 'ADD CONSTRAINT returnfkFOREIGN KEY (return_id)REFERENCES samples(id),' 'ADD CONSTRAINT parent_call_pathfk FOREIGN KEY (parent_call_path_id) REFERENCES call_paths (id)') do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)') + do_query(query, 'CREATE INDEX pid_idx ON calls (parent_id)') if (unhandled_count): print datetime.datetime.today(), "Warning: ", unhandled_count, " unhandled events" @@ -728,7 +732,7 @@ def call_path_table(cp_id, parent_id, symbol_id, ip, *x): value = struct.pack(fmt, 4, 8, cp_id, 8, parent_id, 8, symbol_id, 8, ip) call_path_file.write(value) -def call_return_table(cr_id, thread_id, comm_id, call_path_id, call_time, return_time, branch_count, call_id, return_id, parent_call_path_id, flags, *x): - fmt = "!hiqiqiqiqiqiqiqiqiqiqii" - value = struct.pack(fmt, 11, 8, cr_id, 8, thread_id, 8, comm_id, 8, call_path_id, 8, call_time, 8, return_time, 8, branch_count, 8, call_id, 8, return_id, 8, parent_call_path_id, 4, flags) +def call_return_table(cr_id, thread_id, comm_id, call_path_id, call_time, return_time, branch_count, call_id, return_id, parent_call_path_id, flags, parent_id, *x): + fmt = "!hiqiqiqiqiqiqiqiqiqiqiiiq" + value = struct.pack(fmt, 12, 8, cr_id, 8, thread_id, 8, comm_id, 8, call_path_id, 8, call_time, 8, return_time, 8, branch_count, 8, call_id, 8, return_id, 8, parent_call_path_id, 4, flags, 8, parent_id) call_file.write(value)