Received: by 10.192.165.156 with SMTP id m28csp2893697imm; Sun, 15 Apr 2018 11:37:15 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/XWErkCAnbV75XU2bj29bVO7cfOnLFCxbDx+i5APmbPa0Gg37dFqNA21i+ymK6cEMI9E3j X-Received: by 10.167.129.10 with SMTP id b10mr19113353pfi.186.1523817435305; Sun, 15 Apr 2018 11:37:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523817435; cv=none; d=google.com; s=arc-20160816; b=dTOq+Jc7cs46liygoh4vkP6w/I30zcjj1G+RYZdsK9F3hcf55KGOYTtdMsElRz4p/i +x8prXpoCwW5RW2zy53uOjTTNp6yALxF6BW2EVMKxymKGaye5j/K+zalPQyKalwgDtx3 XeFK1y+zYv5yTiUXfJOfUffa+cd6wgzeubNYheOiw0+pw51u/yGtAcnUoxAXuUpnO6Ha Yeog0qEEdhTmCKogqzbHsw+xnn2dZqeCM5WxYwAqmQ56/ASeWCNVil9YuBMc5bxUqRAR YqSFPacPDAT+UZxoiN8spg7C4KNxdmJLg9mi8nty02oP2aDZ/ranAbddBlrWkgUjSgyK nrbw== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=0r3dFcx+/NtLv3xat+yijM3HpPa5WsYfB6gKch2wnt4=; b=ZRyPUrD9XGkjLE91l+6tVxMY9jJTca9wX9LkwSVnjP1FAH8iwHPWLVTFzDXDSC9SfE 5a2BKq1ysWicsPNEVxMwuj2ejfLs/QRFa9wpL+AQyr9CXoVIBmwJeKyswehBlucz3L43 PA2HBQxF8vZ1d0TKsWNLyzysqofSB0AIaemSAdQ3/U+UlmTeYMppqiCcm3Ie9bijB1PV jTBKWbkfNEZ+sS2fbGLF2NGR7ekcDQQEbgQ3J5HioG9FbW4exzRfu32pvIjaz9zGJCyq gYfC5+G0sUpow8rRB2z/eMHYtzcrp60Bf6lFb+Bexe/pBLiMjQx6N4YPA+IruLrRa2si CQaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Ct46FIv8; dkim=fail header.i=@linux-foundation.org header.s=google header.b=L5D6ihoK; 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 9si9244553pfh.242.2018.04.15.11.37.01; Sun, 15 Apr 2018 11:37:15 -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=fail header.i=@gmail.com header.s=20161025 header.b=Ct46FIv8; dkim=fail header.i=@linux-foundation.org header.s=google header.b=L5D6ihoK; 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 S1752871AbeDOSeU (ORCPT + 99 others); Sun, 15 Apr 2018 14:34:20 -0400 Received: from mail-io0-f179.google.com ([209.85.223.179]:46023 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752527AbeDOSeS (ORCPT ); Sun, 15 Apr 2018 14:34:18 -0400 Received: by mail-io0-f179.google.com with SMTP id 141so15532146iou.12; Sun, 15 Apr 2018 11:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=0r3dFcx+/NtLv3xat+yijM3HpPa5WsYfB6gKch2wnt4=; b=Ct46FIv86XUYHv1XsyANGZh1QxbIj/sivJe5Xr93a0YMbSOMaqcJpd+8JzxXli61cy sdtAAYLaFn8w7TZQSc9p2IIjjfzw6NLV0K18U5cKKdb7OB7rNYwqfuMK9IgLtIhNzAhn z7OebYou2bYoW3Sr7AOGD91RDFIWScvTJXRwcaOg7DWJ7hNdWockGJbrN5Ae+I4wOga3 6I1ANvMZffZjFfRVNWATiuZus44J7CDAkiDbi3QAdCeTBWkSItdUBz70yiFyFFTToXuS GMisE6ZZctjGuAdNR38fhOd5+4DGZEgPss61any7hHRuts59ZRSJ2iXGnw8CZv27NdTg Ravw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=0r3dFcx+/NtLv3xat+yijM3HpPa5WsYfB6gKch2wnt4=; b=L5D6ihoKnAHg3ebi+HR4/4vqQhnsKbEQpKbLxeAeUYiPHLepUneCn+ePWYIX3LN8oQ 5iXHtrf78Q9d48/3b7oMDRUVvwuIa7fNr3RIYrgSKxVd91Xz/p2krCMHtNbZoCrFeGXx 4NEHnoCDedBlGVc/c5XUGqoAHN5w1gH1yntyI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=0r3dFcx+/NtLv3xat+yijM3HpPa5WsYfB6gKch2wnt4=; b=VMeOK75asydbgS6cqU5ed6O6RU4kuGRyrfWuEAX92Qkz+RIlfyqhhA6QpYLEBkwExk 4qzBVFDC8GezcEIDgJ3Kfsexcf4tsT6E5DHIt8Yh6MgxU6ex1ev1nefnb1e4Ly5tEzYu 0VKtYVDW6F6yu2N6vwylY/YKiT3bow7MkzQmvrQcn54CvPQd4oHx8noMEfrh4881YvzK SqepSNqqINZnLEEQnVG07OjG9TvReSZj09Mtha2RfOqNPTnnBKlc2lJCh5KIxjOENEjX SXYMk3d+y6wsLKyIDhxBNUyWRbt4x6Kb57JeLBmUqrIU1iKTdVZyIB+BF2tC03e74cxF Zu0Q== X-Gm-Message-State: ALQs6tBN8nI4Ujio5WVE2yPbD6LaGmATm8ymx2uqAMSax5sR+lkmnoRf uV6E2CRLrvIrW1VY4ZD/qx1oxsaFdOQN1SbC4QLry6Cz X-Received: by 10.107.175.219 with SMTP id p88mr20422699ioo.257.1523817257894; Sun, 15 Apr 2018 11:34:17 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.95.15 with HTTP; Sun, 15 Apr 2018 11:34:17 -0700 (PDT) In-Reply-To: <20180415005056.GX30522@ZenIV.linux.org.uk> References: <20180413181350.88831-1-khazhy@google.com> <20180413202823.204377-1-khazhy@google.com> <20180413141430.2788e2562e3e24bd273fe78b@linux-foundation.org> <3362fb2d-85ff-86af-399f-698c986e46cc@suse.com> <20180414080206.GV30522@ZenIV.linux.org.uk> <20180414205846.GW30522@ZenIV.linux.org.uk> <20180415005056.GX30522@ZenIV.linux.org.uk> From: Linus Torvalds Date: Sun, 15 Apr 2018 11:34:17 -0700 X-Google-Sender-Auth: -74GhxaSDtpvH5kD8KXmrmb3VKc Message-ID: Subject: Re: [PATCH] fs/dcache.c: re-add cond_resched() in shrink_dcache_parent() To: Al Viro Cc: Nikolay Borisov , Andrew Morton , Khazhismel Kumykov , linux-fsdevel , Linux Kernel Mailing List , David Rientjes , Goldwyn Rodrigues , Jeff Mahoney , Davidlohr Bueso 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 Sat, Apr 14, 2018 at 5:51 PM, Al Viro wrote: >> if (!list_empty(&data.select.found)) That was obviously meant to be just if (data.select.found) I had just cut-and-pasted a bit too much. > You would have to do the same in check_and_drop() as well, > and that brings back d_invalidate()/d_invalidate() livelock > we used to have. See 81be24d263db... Ugh. These are all really incestuous and very intertwined. Yes. > I'm trying to put something together, but the damn thing is > full of potential livelocks, unfortunately ;-/ Will send > a followup once I have something resembling a sane solution... Ok, that patch of yours looks like a nice cleanup, although *please* don't do this: - struct detach_data *data = _data; - if (d_mountpoint(dentry)) { __dget_dlock(dentry); - data->mountpoint = dentry; + *(struct dentry **)_data = dentry; Please keep the temporary variable, and make it do + struct dcache **victim = _victim; ... + *victim = dentry; to kind of match the caller, which does d_walk(dentry, &victim, find_submount); because I abhor those casts inside code, and we have a pattern of passing 'void *_xyz' to callback functions and then making the right type by that kind of struct right_type *xyz = _xyz; at the very top of the function. No, it's obviously not type-safe, but at least it's _legible_, and is a pattern, while that "let's randomly just do a cast in the middle of the code" is just nasty. Side note: I do feel like "d_walk()" should be returning whether it terminated early or not. For example, this very same code in the caller does + struct dentry *victim = NULL; + d_walk(dentry, &victim, find_submount); + if (!victim) { but in many ways it would be more natural to just check the exit condition, and + struct dentry *victim; + if (!d_walk(dentry, &victim, find_submount)) { don't you think? Because that matches the actual setting condition in the find_submount() callback. There are other situations where the same thing is true: that path_check_mount() currently has that "info->mounted" flag, but again, it could be replaced by just checking what the quit condition was, and whether we terminated early or not. Because the two are 100% equivalent, and the return value in many ways would be more logical, I feel. (I'm not sure if we should just return the actual exit condition - defaulting to D_WALK_CONTINUE if there was nothing to walk at all - or whether we should just return a boolean for "terminated early") Hmm? Linus