Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1773396imm; Thu, 27 Sep 2018 02:13:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV62m2r+IO0hbsTjzsVyr0xsf8f8Pl9riEU8wva6kIGM6LYoBNu3XhWngC13ZAYUhfGVAy5SO X-Received: by 2002:a62:6eca:: with SMTP id j193-v6mr10371648pfc.256.1538039588012; Thu, 27 Sep 2018 02:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039587; cv=none; d=google.com; s=arc-20160816; b=ivF7mEkDDyXz+EfgnL5g5jDpdAUfsI43DflAZkVIHzUeVmXn3l4PUt1mHNiQNefvP2 iv+LEjrkTHo3dfczKXDi6tbD7sF3ccIaU3ysG77LI2WjAlKZ9xhXsDioFJoSs+aLCP38 xnyK1Fk+Vx0rdSd3r9KzXUj6bSjtGPGan0iGCX84Cwq6qqrqQGwbNWmorG/kE29n6N34 tsFwGAeJJsW8zKiBfA6i1tPK5OArOdDaDySz/1AChkYOhr1c63qVYZ6fCRrUVWpp1Vbs LDzGA8ptMFf5pRk+WRjV4JKN3se1aqINQA4IhVztNx6tS2vd3VXRGwUaLJq0Eu44MEIM ycwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=lOdfLnRbMnp5y/N2kqUzDrV6j5Ae1PqMUPkbu92NhSg=; b=xQxX300RC0Kz3H2USr3nS3YBWEHYHs1TN70B0LThn/jpqF+70BPfhogWiRBhvWI9KZ 5bhG+T2e3aiacNnNazAAMJJn7YnF+kHBmtn3mJcpPi3OMxU5zVHMtxCDpoJkqPieiCSB 2FVo7lbhbL4u71hOBfjpo9K94SqL4MucDOIGmKoerlYptU+7wjB56HnvFM1VWRFpLIjF GMu4aucPgTvQOdRoPQ1zEswnqXoRxqssv5KlRysthy5zzxi9jnN/7OaHVBOrx5aT00gI UIO8h1znJMBMpfbK4pUCVgSAvY8rJWM7pCZf7BSUeyTdUvxoDV0MFYbH0EPG2s1VKlxC Q8Qg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f6-v6si1468765pgg.182.2018.09.27.02.12.53; Thu, 27 Sep 2018 02:13:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728185AbeI0P2F (ORCPT + 99 others); Thu, 27 Sep 2018 11:28:05 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:55180 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727417AbeI0P2E (ORCPT ); Thu, 27 Sep 2018 11:28:04 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9DF191117; Thu, 27 Sep 2018 09:10:48 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Behmer , Vaibhav Nagarnaik , "Steven Rostedt (VMware)" Subject: [PATCH 4.18 48/88] ring-buffer: Allow for rescheduling when removing pages Date: Thu, 27 Sep 2018 11:03:29 +0200 Message-Id: <20180927090306.659733490@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vaibhav Nagarnaik commit 83f365554e47997ec68dc4eca3f5dce525cd15c3 upstream. When reducing ring buffer size, pages are removed by scheduling a work item on each CPU for the corresponding CPU ring buffer. After the pages are removed from ring buffer linked list, the pages are free()d in a tight loop. The loop does not give up CPU until all pages are removed. In a worst case behavior, when lot of pages are to be freed, it can cause system stall. After the pages are removed from the list, the free() can happen while the work is rescheduled. Call cond_resched() in the loop to prevent the system hangup. Link: http://lkml.kernel.org/r/20180907223129.71994-1-vnagarnaik@google.com Cc: stable@vger.kernel.org Fixes: 83f40318dab00 ("ring-buffer: Make removal of ring buffer pages atomic") Reported-by: Jason Behmer Signed-off-by: Vaibhav Nagarnaik Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ring_buffer.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c @@ -1545,6 +1545,8 @@ rb_remove_pages(struct ring_buffer_per_c tmp_iter_page = first_page; do { + cond_resched(); + to_remove_page = tmp_iter_page; rb_inc_page(cpu_buffer, &tmp_iter_page);