public inbox for linux-cifs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Steve French <smfrench@gmail.com>
Cc: Steve French <sfrench@samba.org>,
	linux-cifs <linux-cifs@vger.kernel.org>,
	samba-technical <samba-technical@lists.samba.org>
Subject: Re: [PATCH 1/1] cifs: remove unnecessary oom message
Date: Fri, 18 Jun 2021 18:15:52 +0800	[thread overview]
Message-ID: <04b147c2-84bb-54a8-caca-d463a1fa917b@huawei.com> (raw)
In-Reply-To: <CAH2r5msQ4NKah88JOo4yX9jZtogLnfscULRtvbn21+aP=0x=jQ@mail.gmail.com>



On 2021/6/18 12:09, Steve French wrote:
> I am curious the motivation for these - I agree that removing the
> debug messages saves (albeit trivial amount of) memory but curious
> about how other areas of the kernel handle logging low memory/out of
> memory issues?

$ scripts/checkpatch.pl --types=OOM_MESSAGE -- $(git ls-files kernel/) > err.txt
$ cat err.txt | grep WARNING | wc -l
12

$ git grep -wn k.alloc kernel/ | wc -l
469
$ git grep -wn kstrdup kernel/ | wc -l
88
... ... Other kernel memory allocation APIs are omitted.

You see, the vast majority are not printed.


> 
> On Thu, Jun 17, 2021 at 3:42 AM Zhen Lei <thunder.leizhen@huawei.com> wrote:
>>
>> Fixes scripts/checkpatch.pl warning:
>> WARNING: Possible unnecessary 'out of memory' message
>>
>> Remove it can help us save a bit of memory.
>>
>> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
>> ---
>>  fs/cifs/cifsencrypt.c | 4 +---
>>  fs/cifs/connect.c     | 6 +-----
>>  fs/cifs/sess.c        | 6 +-----
>>  fs/cifs/smb2pdu.c     | 2 --
>>  4 files changed, 3 insertions(+), 15 deletions(-)
>>
>> diff --git a/fs/cifs/cifsencrypt.c b/fs/cifs/cifsencrypt.c
>> index b8f1ff9a83f3..74f16730e502 100644
>> --- a/fs/cifs/cifsencrypt.c
>> +++ b/fs/cifs/cifsencrypt.c
>> @@ -787,10 +787,8 @@ calc_seckey(struct cifs_ses *ses)
>>         get_random_bytes(sec_key, CIFS_SESS_KEY_SIZE);
>>
>>         ctx_arc4 = kmalloc(sizeof(*ctx_arc4), GFP_KERNEL);
>> -       if (!ctx_arc4) {
>> -               cifs_dbg(VFS, "Could not allocate arc4 context\n");
>> +       if (!ctx_arc4)
>>                 return -ENOMEM;
>> -       }
>>
>>         arc4_setkey(ctx_arc4, ses->auth_key.response, CIFS_SESS_KEY_SIZE);
>>         arc4_crypt(ctx_arc4, ses->ntlmssp->ciphertext, sec_key,
>> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
>> index 05f5c84a63a4..b52bb6dc6ecb 100644
>> --- a/fs/cifs/connect.c
>> +++ b/fs/cifs/connect.c
>> @@ -97,10 +97,8 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
>>         len = strlen(server->hostname) + 3;
>>
>>         unc = kmalloc(len, GFP_KERNEL);
>> -       if (!unc) {
>> -               cifs_dbg(FYI, "%s: failed to create UNC path\n", __func__);
>> +       if (!unc)
>>                 return -ENOMEM;
>> -       }
>>         scnprintf(unc, len, "\\\\%s", server->hostname);
>>
>>         rc = dns_resolve_server_name_to_ip(unc, &ipaddr);
>> @@ -1758,8 +1756,6 @@ cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses)
>>         if (is_domain && ses->domainName) {
>>                 ctx->domainname = kstrdup(ses->domainName, GFP_KERNEL);
>>                 if (!ctx->domainname) {
>> -                       cifs_dbg(FYI, "Unable to allocate %zd bytes for domain\n",
>> -                                len);
>>                         rc = -ENOMEM;
>>                         kfree(ctx->username);
>>                         ctx->username = NULL;
>> diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c
>> index cd19aa11f27e..cc97b2981c3d 100644
>> --- a/fs/cifs/sess.c
>> +++ b/fs/cifs/sess.c
>> @@ -602,10 +602,8 @@ int decode_ntlmssp_challenge(char *bcc_ptr, int blob_len,
>>         if (tilen) {
>>                 ses->auth_key.response = kmemdup(bcc_ptr + tioffset, tilen,
>>                                                  GFP_KERNEL);
>> -               if (!ses->auth_key.response) {
>> -                       cifs_dbg(VFS, "Challenge target info alloc failure\n");
>> +               if (!ses->auth_key.response)
>>                         return -ENOMEM;
>> -               }
>>                 ses->auth_key.len = tilen;
>>         }
>>
>> @@ -1338,8 +1336,6 @@ sess_auth_kerberos(struct sess_data *sess_data)
>>         ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
>>                                          GFP_KERNEL);
>>         if (!ses->auth_key.response) {
>> -               cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n",
>> -                        msg->sesskey_len);
>>                 rc = -ENOMEM;
>>                 goto out_put_spnego_key;
>>         }
>> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
>> index c205f93e0a10..2b978564e188 100644
>> --- a/fs/cifs/smb2pdu.c
>> +++ b/fs/cifs/smb2pdu.c
>> @@ -1355,8 +1355,6 @@ SMB2_auth_kerberos(struct SMB2_sess_data *sess_data)
>>                 ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len,
>>                                                  GFP_KERNEL);
>>                 if (!ses->auth_key.response) {
>> -                       cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n",
>> -                                msg->sesskey_len);
>>                         rc = -ENOMEM;
>>                         goto out_put_spnego_key;
>>                 }
>> --
>> 2.25.1
>>
>>
> 
> 


      reply	other threads:[~2021-06-18 10:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17  8:41 [PATCH 1/1] cifs: remove unnecessary oom message Zhen Lei
2021-06-18  4:09 ` Steve French
2021-06-18 10:15   ` Leizhen (ThunderTown) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04b147c2-84bb-54a8-caca-d463a1fa917b@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=sfrench@samba.org \
    --cc=smfrench@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox