Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp33895imm; Tue, 22 May 2018 13:29:35 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqSp5oTmK4Zune3/HsjiKCK2emCJDfaAKMEaJc5Zf3VuSzK3beS+8al7RapNUn8BcZFf9l+ X-Received: by 2002:a63:ac1a:: with SMTP id v26-v6mr20628141pge.105.1527020974950; Tue, 22 May 2018 13:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527020959; cv=none; d=google.com; s=arc-20160816; b=YbTPTAx6GN44MCFBNVN8y57dZXoU/o3JZ+p4YywGEp0KXyUZR5MDd77RVYZkZblANB 4x6hp8jpY1uSUS/l+kKBnArguEUhmjjMvYfm7F0Il2ZVZmphfPZT0Y4tBpyjSio6SfOL drSTje7NPGhIFThHyfEpjkL+2Z4cxUqsqv5RTmBJu6b3PVMZkRGBFIe9m0GHe00sOVNi NbFFk3t+59zW+lvw15oeFpZC6CnAL8fNcNGr1NzC2mSh8ZrC7AOfbCoejZ7VDra0JLa9 4TiI8Wt5xZw2urEccBZvsH3JlNzxwNze1dYhipQVUmEmkgh22FP9Jno3/X7xXPD5luH6 b5+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature :arc-authentication-results; bh=ARuXOa8vtNWxiOQJQHwBhzYF6dU4ZCgi98U4dtQWfXY=; b=S109DQPYrSJWLhg8yyvzfSoH591vYiXPicvRYqtTVygN66T8pNUiyzwvXm+mX+L9TZ gnD0hNk4O/FFfNt5eklCfjz6k2SU79zOOSG1fhEJghnVmM12UDJmv670sSVRXNoArTS2 aJ9xKVZWC7K9m4N2QxbwW7dlbul/qMFLhjilAqqtFdaiZ7Urp9E7VGH81cmQEedfgNTi DunJUJQJtgIz5BVLbIAPnYClIvIMVvXLWG0lizsClB3PColJzPhjHY0JYrOQtmg5CgkD XtoqdHsJes8IvMjdBtCNBHvgCdDu5zn4uLac5Qdfh5MZJN+v3VvEn44r/XbYiCvZXMig Jx+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O3aoqjuc; 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 c21-v6si17118403plo.51.2018.05.22.13.29.05; Tue, 22 May 2018 13:29:19 -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; dkim=pass header.i=@linux-foundation.org header.s=google header.b=O3aoqjuc; 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 S1752789AbeEVU1a (ORCPT + 99 others); Tue, 22 May 2018 16:27:30 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:53328 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752161AbeEVU13 (ORCPT ); Tue, 22 May 2018 16:27:29 -0400 Received: by mail-it0-f45.google.com with SMTP id n64-v6so1596353itb.3 for ; Tue, 22 May 2018 13:27:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ARuXOa8vtNWxiOQJQHwBhzYF6dU4ZCgi98U4dtQWfXY=; b=O3aoqjuc83uV/M8VPrEtEk4u3uDWXYpLAHCAMGugTGhVqAi1MphsE/wobQqg+jPldN U6KtZitGZySpz3tcpPx++iTnP7QOQXydaBdDMqSB9A651nFxU7G8PWIUFTYRbxAeSvzC NHUF02A9RJhUThGgemxKmpBHVv6E3nkOjjQFc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ARuXOa8vtNWxiOQJQHwBhzYF6dU4ZCgi98U4dtQWfXY=; b=pXcFTckgtWvMPA4wzKSeuPGcTSL23RpNiOUySRnnrUmb498KPC6XcJT29iF+AlTYV0 iAB/4UeT8ZX+z0KHUhWhpMuvh+tzc/nMPdMXrQwELoMgO4h6fnorVxHDsm9ciQuQPAtB 7uX83I2xXlVBOmTzmkVbu21zB2zGW4WZVskfg98vZtjSJQU19N6XdsrFYinKTw0X/K/p LJCeLrOOBIuE7P8bo59vfWWSytcAFs6UjuIR0O4iv1Xp06rHmeGJexNrsrL1SREj1sXE h9M9luWa4XWgl0JO9vm+kynVgDaUXWffqPRl8ruAEUqmS/T/Iva47yNv0b0XXscF1T1m 7EsQ== X-Gm-Message-State: ALKqPwfWd1+C+mSuNZUtEGqtySk62dtIl36M0DdzU8k7oWcX8NGNKljl 8B6+S1VK5SkpQSxzKLJH8eSFpqOG2cQCN3bMhUM= X-Received: by 2002:a24:21ca:: with SMTP id e193-v6mr2651202ita.108.1527020848401; Tue, 22 May 2018 13:27:28 -0700 (PDT) MIME-Version: 1.0 References: <0879f797135033e05e8e9166a3c85628@codeaurora.org> In-Reply-To: <0879f797135033e05e8e9166a3c85628@codeaurora.org> From: Linus Torvalds Date: Tue, 22 May 2018 13:27:17 -0700 Message-ID: Subject: Re: write_lock_irq(&tasklist_lock) To: psodagud@codeaurora.org Cc: Kees Cook , Andy Lutomirski , Will Drewry , Andrew Morton , Rik van Riel , Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Eric Biggers , Frederic Weisbecker , sherryy@android.com, Vegard Nossum , Christoph Lameter , Andrea Arcangeli , Sasha Levin , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 22, 2018 at 12:40 PM Sodagudi Prasad wrote: > Have you observed this type of issues with tasklist_lock ? tasklist_lock remains pretty painful. It covers too much, but trying to split it up has never worked well. It's usually not a huge problem because there are so few writers, but what you're seeing is the writer starvation issue because readers can be plentiful. > Do we need write_lock_irq(&tasklist_lock) in below portion of code ? Can > I use write_unlock instead of write_lock_irq in portion of code? You absolutely need write_lock_irq(), because taking the tasklist_lock without disabling interrupts will deadlock very quickly due to an interrupt taking the tasklist_lock for reading. That said, the write_lock_irq(&tasklist_lock) could possibly be replaced with something like static void tasklist_write_lock(void) { unsigned long flags; local_irq_save(flags); while (!write_trylock(&tasklist_lock)) { local_irq_restore(flags); do { cpu_relax(); } while (write_islocked(&tasklist_lock)); local_irq_disable(); } } but we don't have that "write_islocked()" function. So the above would need more work, and is entirely untested anyway, obviously. Linus